Comparing version 1.1.0 to 1.2.0
{ | ||
"name": "spaceman", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Manage monorepo workspaces with a prompt-based CLI", | ||
@@ -5,0 +5,0 @@ "author": "Dave Stewart", |
@@ -77,3 +77,3 @@ # Spaceman | ||
Packages | ||
install | ||
install | ||
uninstall | ||
@@ -119,2 +119,14 @@ update | ||
To exclude scripts (for example those starting with `~`) you can add an exclusion filter in `package.json`: | ||
```json | ||
{ | ||
"spaceman": { | ||
"scripts": { | ||
"exclude": "^~" | ||
} | ||
} | ||
} | ||
``` | ||
## Packages | ||
@@ -121,0 +133,0 @@ |
const Fs = require('fs') | ||
const rimraf = require('rimraf') | ||
const { toSentence, toCamel, uniq, sortObject, removeItem, toArray } = require('./utils') | ||
const { ask, confirm, _ask, _heading, makeChoicesGroup } = require('./utils/enquirer') | ||
const { log, exec, exit } = require('./utils/shell') | ||
const { getSetting } = require('./utils/spaceman') | ||
const { ROOT } = require('./utils/vars') | ||
const { | ||
@@ -9,9 +14,13 @@ getWorkspaces, | ||
getWorkspaceGroups, | ||
getWorkspaceGroupFolders | ||
getWorkspaceGroupFolders, | ||
} = require('./workspaces') | ||
const { toSentence, toCamel, uniq, sortObject, removeItem, toArray } = require('./utils') | ||
const { isValidName, getCommand, getScripts, getDependencies, readPackage, writePackage, getManager } = require('./utils/package') | ||
const { ask, confirm, _ask, _heading, makeChoicesGroup } = require('./utils/enquirer') | ||
const { log, exec, exit } = require('./utils/shell') | ||
const { ROOT } = require('./utils/vars') | ||
const { | ||
isValidName, | ||
getCommand, | ||
getScripts, | ||
getDependencies, | ||
readPackage, | ||
writePackage, | ||
getManager, | ||
} = require('./utils/package') | ||
@@ -23,5 +32,8 @@ // --------------------------------------------------------------------------------------------------------------------- | ||
function chooseScript (input = {}) { | ||
// make options | ||
const makeOption = (path, name) => { | ||
return { | ||
choice: `${path || '/'}: `.grey + name, | ||
choice: path | ||
? path.replace(/^\//, '').grey + ' ' + name | ||
: name, | ||
path, | ||
@@ -38,3 +50,14 @@ name, | ||
}, []) | ||
const items = [...main, ...other] | ||
// set up exclusion filter | ||
const exclude = getSetting('scripts.exclude') | ||
const rxExclude = exclude ? new RegExp(String(exclude)) : null | ||
const fnInclude = rxExclude | ||
? choice => !rxExclude.test(choice.name) | ||
: () => true | ||
// build items | ||
const items = [...main, ...other].filter(fnInclude) | ||
// build choices | ||
const choices = items.map(item => item.choice) | ||
@@ -48,3 +71,3 @@ | ||
return items.find(item => item.choice === choice) | ||
} | ||
}, | ||
} | ||
@@ -74,3 +97,3 @@ return ask('script', 'Script', options, input) | ||
return !!answer | ||
} | ||
}, | ||
} | ||
@@ -112,3 +135,3 @@ return ask(name, message, options, input).then(chooseDepType) | ||
development: 'dev', | ||
peer: 'peer' | ||
peer: 'peer', | ||
} | ||
@@ -119,3 +142,3 @@ const options = { | ||
'development', | ||
'peer' | ||
'peer', | ||
], | ||
@@ -142,3 +165,3 @@ result (answer) { | ||
const options = { | ||
choices: getWorkspacesChoices() | ||
choices: getWorkspacesChoices(), | ||
} | ||
@@ -173,3 +196,3 @@ return ask('workspace', 'Workspace', options, input) | ||
return true | ||
} | ||
}, | ||
} | ||
@@ -204,3 +227,3 @@ const message = `${toSentence(type)} workspace` | ||
return answer.trim().toLowerCase() + '/*' | ||
} | ||
}, | ||
} | ||
@@ -223,3 +246,3 @@ | ||
type: 'select', | ||
choices: [...getWorkspaceGroups(), ROOT] | ||
choices: [...getWorkspaceGroups(), ROOT], | ||
} | ||
@@ -256,3 +279,3 @@ return ask('group', 'Workspace group', options, input) | ||
return true | ||
} | ||
}, | ||
})) | ||
@@ -281,3 +304,3 @@ .then(_ask('description', 'Description')) | ||
...input, | ||
options | ||
options, | ||
} | ||
@@ -314,3 +337,3 @@ }) | ||
return true | ||
} | ||
}, | ||
} | ||
@@ -366,3 +389,3 @@ return ask('confirm', 'Type workspace folder name to confirm removal'.red, options, input) | ||
`.${path}/package-lock.json`, | ||
`.${path}/node_modules/` | ||
`.${path}/node_modules/`, | ||
] | ||
@@ -379,3 +402,3 @@ return paths.filter(path => Fs.existsSync(path)) | ||
} | ||
// rimraf can sometimes fail, so try again if it does | ||
// rimraf can sometimes fail, so try again if it does | ||
catch (err) { | ||
@@ -456,4 +479,4 @@ paths.forEach(path => { | ||
build: build || undefined, | ||
test: test || 'echo "Error: no test specified" && exit 1' | ||
} | ||
test: test || 'echo "Error: no test specified" && exit 1', | ||
}, | ||
} | ||
@@ -613,3 +636,3 @@ | ||
'update', | ||
'reset' | ||
'reset', | ||
]), | ||
@@ -620,4 +643,4 @@ makeChoicesGroup('Workspaces', [ | ||
'add', | ||
'remove' | ||
]) | ||
'remove', | ||
]), | ||
] | ||
@@ -717,3 +740,3 @@ return Promise | ||
module.exports = { | ||
chooseTask | ||
chooseTask, | ||
} |
const Fs = require('fs') | ||
/** | ||
* Package.json info | ||
* | ||
* @typedef {Object} Package | ||
* @property {string} name The package name | ||
* @property {string[]} [workspaces] A list of workspaces | ||
* @property {Object.<string, string>} [scripts] A list of scripts | ||
* @property {Object.<string, string>} [dependencies] A list of dependencies | ||
* @property {Object.<string, string>} [devDependencies] A list of dev dependencies | ||
* @property {Object.<string, string>} [spaceman] Spaceman settings | ||
*/ | ||
function isValidName (name) { | ||
@@ -4,0 +16,0 @@ const rx = /^[\da-z][-+.\da-z]+$/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37585
11
1118
252