Skip to content

Commit

Permalink
chore: remove lerna as yarn supports enough stuff now (#3243)
Browse files Browse the repository at this point in the history
  • Loading branch information
ForbesLindesay committed May 1, 2020
1 parent b043d7c commit f97ebdb
Show file tree
Hide file tree
Showing 80 changed files with 3,956 additions and 5,383 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/rollingversions.yml
@@ -0,0 +1,33 @@
name: Release
on:
repository_dispatch:
types: [rollingversions_publish_approved]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn install --forzen-lockfile
- run: yarn prettier:check
- run: yarn test

publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- run: yarn install --forzen-lockfile
- run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- run: npx rollingversions publish
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,27 @@
name: Test

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn install --forzen-lockfile
- run: yarn prettier:check
- run: yarn test
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

1 change: 0 additions & 1 deletion .yarnrc

This file was deleted.

8 changes: 0 additions & 8 deletions lerna.json

This file was deleted.

20 changes: 7 additions & 13 deletions package.json
@@ -1,22 +1,22 @@
{
"name": "pug-monorepo",
"private": true,
"workspaces": [
"packages/*"
],
"devDependencies": {
"coveralls": "3.0.9",
"jest": "24.9.0",
"lerna": "3.20.2",
"prettier": "1.19.1"
},
"repository": {
"type": "git",
"url": "https://github.com/pugjs/pug.git"
},
"scripts": {
"prettier:check": "prettier --ignore-path .gitignore --list-different './**/*.js'",
"format": "prettier --ignore-path .gitignore --write './**/*.js'",
"bootstrap": "lerna bootstrap",
"clean": "lerna clean",
"release": "lerna publish",
"pretest": "lerna run pretest",
"pretest": "wsrun --stages --exclude-missing --fast-exit --collect-logs build",
"test": "jest",
"coverage": "jest --coverage",
"coveralls": "jest --coverage --coverageReporters=text-lcov | coveralls",
Expand All @@ -30,13 +30,7 @@
]
},
"license": "MIT",
"workspaces": [
"packages/*"
],
"resolutions": {
"jstransformer-markdown-it": "2.0.0",
"mkdirp": "0.5.1",
"shallow-clone": "2.0.0",
"stylus": "0.54.5"
"dependencies": {
"wsrun": "^5.2.0"
}
}
60 changes: 44 additions & 16 deletions packages/pug-attrs/index.js
Expand Up @@ -6,10 +6,10 @@ var runtime = require('pug-runtime');
var stringify = require('js-stringify');

function isConstant(src) {
return constantinople(src, {pug: runtime, 'pug_interp': undefined});
return constantinople(src, {pug: runtime, pug_interp: undefined});
}
function toConstant(src) {
return constantinople.toConstant(src, {pug: runtime, 'pug_interp': undefined});
return constantinople.toConstant(src, {pug: runtime, pug_interp: undefined});
}

module.exports = compileAttrs;
Expand All @@ -21,15 +21,23 @@ module.exports = compileAttrs;
*/
function compileAttrs(attrs, options) {
assert(Array.isArray(attrs), 'Attrs should be an array');
assert(attrs.every(function (attr) {
return attr &&
typeof attr === 'object' &&
typeof attr.name === 'string' &&
(typeof attr.val === 'string' || typeof attr.val === 'boolean') &&
typeof attr.mustEscape === 'boolean';
}), 'All attributes should be supplied as an object of the form {name, val, mustEscape}');
assert(
attrs.every(function(attr) {
return (
attr &&
typeof attr === 'object' &&
typeof attr.name === 'string' &&
(typeof attr.val === 'string' || typeof attr.val === 'boolean') &&
typeof attr.mustEscape === 'boolean'
);
}),
'All attributes should be supplied as an object of the form {name, val, mustEscape}'
);
assert(options && typeof options === 'object', 'Options should be an object');
assert(typeof options.terse === 'boolean', 'Options.terse should be a boolean');
assert(
typeof options.terse === 'boolean',
'Options.terse should be a boolean'
);
assert(
typeof options.runtime === 'function',
'Options.runtime should be a function that takes a runtime function name and returns the source code that will evaluate to that function at runtime'
Expand All @@ -46,7 +54,9 @@ function compileAttrs(attrs, options) {
function addAttribute(key, val, mustEscape, buf) {
if (isConstant(val)) {
if (options.format === 'html') {
var str = stringify(runtime.attr(key, toConstant(val), mustEscape, options.terse));
var str = stringify(
runtime.attr(key, toConstant(val), mustEscape, options.terse)
);
var last = buf[buf.length - 1];
if (last && last[last.length - 1] === str[0]) {
buf[buf.length - 1] = last.substr(0, last.length - 1) + str.substr(1);
Expand All @@ -62,7 +72,18 @@ function compileAttrs(attrs, options) {
}
} else {
if (options.format === 'html') {
buf.push(options.runtime('attr') + '("' + key + '", ' + val + ', ' + stringify(mustEscape) + ', ' + stringify(options.terse) + ')');
buf.push(
options.runtime('attr') +
'("' +
key +
'", ' +
val +
', ' +
stringify(mustEscape) +
', ' +
stringify(options.terse) +
')'
);
} else {
if (mustEscape) {
val = options.runtime('escape') + '(' + val + ')';
Expand All @@ -72,7 +93,7 @@ function compileAttrs(attrs, options) {
}
}

attrs.forEach(function(attr){
attrs.forEach(function(attr) {
var key = attr.name;
var val = attr.val;
var mustEscape = attr.mustEscape;
Expand Down Expand Up @@ -101,16 +122,23 @@ function compileAttrs(attrs, options) {
classesBuf
);
} else {
classes = classes.map(function (cls, i) {
classes = classes.map(function(cls, i) {
if (isConstant(cls)) {
cls = stringify(classEscaping[i] ? runtime.escape(toConstant(cls)) : toConstant(cls));
cls = stringify(
classEscaping[i] ? runtime.escape(toConstant(cls)) : toConstant(cls)
);
classEscaping[i] = false;
}
return cls;
});
addAttribute(
'class',
options.runtime('classes') + '([' + classes.join(',') + '], ' + stringify(classEscaping) + ')',
options.runtime('classes') +
'([' +
classes.join(',') +
'], ' +
stringify(classEscaping) +
')',
false,
classesBuf
);
Expand Down

0 comments on commit f97ebdb

Please sign in to comment.