create-rstack 1.7.2 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -11
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1573,16 +1573,16 @@ function isEmptyDir(path) {
|
|
|
1573
1573
|
}
|
|
1574
1574
|
function logHelpMessage(name, templates) {
|
|
1575
1575
|
src_logger.log(`
|
|
1576
|
-
Usage: create-${name} [options]
|
|
1576
|
+
Usage: create-${name} [dir] [options]
|
|
1577
1577
|
|
|
1578
1578
|
Options:
|
|
1579
1579
|
|
|
1580
|
-
-h, --help
|
|
1581
|
-
-d, --dir
|
|
1582
|
-
-t, --template
|
|
1583
|
-
--tools
|
|
1584
|
-
--override
|
|
1585
|
-
--
|
|
1580
|
+
-h, --help display help for command
|
|
1581
|
+
-d, --dir <dir> create project in specified directory
|
|
1582
|
+
-t, --template <tpl> specify the template to use
|
|
1583
|
+
--tools <tool> select additional tools (biome, eslint, prettier)
|
|
1584
|
+
--override override files in target directory
|
|
1585
|
+
--packageName <name> specify the package name
|
|
1586
1586
|
|
|
1587
1587
|
Templates:
|
|
1588
1588
|
|
|
@@ -1619,7 +1619,7 @@ function upperFirst(str) {
|
|
|
1619
1619
|
}
|
|
1620
1620
|
const readJSON = async (path)=>JSON.parse(await node_fs.promises.readFile(path, 'utf-8'));
|
|
1621
1621
|
const readPackageJson = async (filePath)=>readJSON(node_path.join(filePath, 'package.json'));
|
|
1622
|
-
|
|
1622
|
+
const parseArgv = ()=>{
|
|
1623
1623
|
const argv = minimist_default()(process.argv.slice(2), {
|
|
1624
1624
|
alias: {
|
|
1625
1625
|
h: 'help',
|
|
@@ -1627,8 +1627,14 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
1627
1627
|
t: 'template'
|
|
1628
1628
|
}
|
|
1629
1629
|
});
|
|
1630
|
+
if (!argv.dir && argv._[0]) argv.dir = argv._[0];
|
|
1631
|
+
if (argv['package-name']) argv.packageName = argv['package-name'];
|
|
1632
|
+
return argv;
|
|
1633
|
+
};
|
|
1634
|
+
async function create({ name, root, templates, skipFiles, getTemplateName, mapESLintTemplate, version, noteInformation }) {
|
|
1630
1635
|
console.log('');
|
|
1631
1636
|
src_logger.greet(`◆ Create ${upperFirst(name)} Project`);
|
|
1637
|
+
const argv = parseArgv();
|
|
1632
1638
|
if (argv.help) return void logHelpMessage(name, templates);
|
|
1633
1639
|
const cwd = process.cwd();
|
|
1634
1640
|
const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent);
|
|
@@ -1644,7 +1650,7 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
1644
1650
|
}));
|
|
1645
1651
|
const formatted = formatProjectName(projectName);
|
|
1646
1652
|
const { targetDir } = formatted;
|
|
1647
|
-
const packageName = argv
|
|
1653
|
+
const packageName = argv.packageName || formatted.packageName;
|
|
1648
1654
|
const distFolder = node_path.isAbsolute(targetDir) ? targetDir : node_path.join(cwd, targetDir);
|
|
1649
1655
|
if (!argv.override && node_fs.existsSync(distFolder) && !isEmptyDir(distFolder)) {
|
|
1650
1656
|
const option = checkCancel(await ve({
|
|
@@ -1682,8 +1688,8 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
1682
1688
|
});
|
|
1683
1689
|
const packageRoot = node_path.resolve(src_dirname, '..');
|
|
1684
1690
|
const agentsMdSearchDirs = [
|
|
1685
|
-
|
|
1686
|
-
|
|
1691
|
+
commonFolder,
|
|
1692
|
+
srcFolder
|
|
1687
1693
|
];
|
|
1688
1694
|
for (const tool of tools){
|
|
1689
1695
|
const toolFolder = node_path.join(packageRoot, `template-${tool}`);
|