-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use
yargs
to organize the scripts into commands
BREAKING CHANGE: the ways to run packages-scripts changed * replace `src`, `dist` with shared variables
- Loading branch information
1 parent
db0d656
commit 550b6df
Showing
43 changed files
with
793 additions
and
497 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function cleanCommandArgs(commandName, rawArgv) { | ||
const args = process.argv.slice(2) | ||
const input = [...rawArgv._] | ||
// if executing this script by another cli program, shift `precommit` itself | ||
if (args[0] === commandName) { | ||
args.shift() | ||
input.shift() | ||
} | ||
|
||
const normalizedArgs = {argv: {...rawArgv, _: input}, args} | ||
|
||
return normalizedArgs | ||
} | ||
|
||
module.exports = { | ||
cleanCommandArgv: cleanCommandArgs, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
exports.command = 'bundle' | ||
|
||
exports.describe = | ||
'Use rollup to compile and bundle source files through a entry file' | ||
|
||
exports.builder = yargs => { | ||
const options = { | ||
'react-native': { | ||
type: 'boolean', | ||
describe: 'Target to React Native execution environment', | ||
defaultDescription: 'false', | ||
}, | ||
node: { | ||
type: 'boolean', | ||
describe: 'Target to Node.js execution environment', | ||
defaultDescription: 'false', | ||
}, | ||
config: { | ||
type: 'string', | ||
describe: 'Pick the rollup configuration file passed to rollup cli', | ||
defaultDescription: 'rollup.config.js', | ||
}, | ||
'size-snapshot': { | ||
type: 'boolean', | ||
describe: | ||
'Enable the output in terminal about the size snapshot of bundles', | ||
default: true, | ||
defaultDescription: 'true', | ||
}, | ||
watch: { | ||
type: 'boolean', | ||
describe: 'Enable watching changes to bundle', | ||
defaultDescription: 'false', | ||
}, | ||
formats: { | ||
type: 'string', | ||
array: true, | ||
defaultDescription: ['esm', 'cjs', 'umd', 'umd.min'], | ||
default: ['esm', 'cjs', 'umd', 'umd.min'], | ||
}, | ||
environment: { | ||
type: 'string', | ||
describe: 'The `--environment` passed to rollup cli', | ||
}, | ||
preact: { | ||
type: 'boolean', | ||
describe: 'The project use preact instead of react', | ||
}, | ||
clean: { | ||
type: 'boolean', | ||
describe: `Don't clean output directory before bundling`, | ||
default: true, | ||
defaultDescription: 'true', | ||
}, | ||
'add-preact-entry': { | ||
type: 'boolean', | ||
describe: `Write an extra entry \`preact\` into package.json`, | ||
default: true, | ||
defaultDescription: 'true', | ||
}, | ||
// sourcemap: { | ||
// type: 'boolean', | ||
// describe: `The \`--sourcemap\` passed to rollup cli`, | ||
// defaultDescription: 'false', | ||
// }, | ||
} | ||
|
||
return yargs.options(options) | ||
} | ||
|
||
exports.handler = argv => { | ||
console.log('Bundling...') | ||
|
||
require('../scripts/build/rollup')(argv) | ||
} |
Oops, something went wrong.