@code-id-labs/cli 1.0.2 → 1.0.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.js +10 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -111,7 +111,7 @@ function getCodeUiDepRange() {
|
|
|
111
111
|
return "^1.0.0";
|
|
112
112
|
}
|
|
113
113
|
function generateStarterFiles(options) {
|
|
114
|
-
const { projectName, appId, primaryColor, iconCollection, prefix } = options;
|
|
114
|
+
const { projectName, appId, primaryColor, iconCollection, prefix, pm = "pnpm" } = options;
|
|
115
115
|
const codeUiRange = getCodeUiDepRange();
|
|
116
116
|
return {
|
|
117
117
|
".gitignore": [
|
|
@@ -122,7 +122,7 @@ function generateStarterFiles(options) {
|
|
|
122
122
|
"*.log",
|
|
123
123
|
""
|
|
124
124
|
].join("\n"),
|
|
125
|
-
"pnpm-workspace.yaml": [
|
|
125
|
+
...pm === "pnpm" ? { "pnpm-workspace.yaml": [
|
|
126
126
|
"allowBuilds:",
|
|
127
127
|
" \"@parcel/watcher\": false",
|
|
128
128
|
" \"@swc/core\": false",
|
|
@@ -143,7 +143,7 @@ function generateStarterFiles(options) {
|
|
|
143
143
|
" - core-js-pure",
|
|
144
144
|
" - unrs-resolver",
|
|
145
145
|
""
|
|
146
|
-
].join("\n"),
|
|
146
|
+
].join("\n") } : {},
|
|
147
147
|
"package.json": JSON.stringify({
|
|
148
148
|
name: projectName,
|
|
149
149
|
type: "module",
|
|
@@ -520,7 +520,8 @@ program.command("create [project-name]").description("Create a new WeChat MiniPr
|
|
|
520
520
|
appId,
|
|
521
521
|
primaryColor,
|
|
522
522
|
iconCollection,
|
|
523
|
-
prefix
|
|
523
|
+
prefix,
|
|
524
|
+
pm
|
|
524
525
|
});
|
|
525
526
|
logger.success(`Scaffolded Code UI project in ${pc.green(targetDir)}`);
|
|
526
527
|
if (runInstall) {
|
|
@@ -545,12 +546,15 @@ program.command("create [project-name]").description("Create a new WeChat MiniPr
|
|
|
545
546
|
});
|
|
546
547
|
program.command("init").description("Initialize Code UI configuration (cui.config.ts, weapp-vite.config.ts, and src/app.css) in an existing weapp-vite project").option("-y, --yes", "Skip prompts and use defaults").option("--primary <color>", "Primary semantic color palette", "red").option("--icons <collection>", "Default Iconify collection", "lucide").option("--prefix <prefix>", "Component tag prefix", "c").option("--install", "Install @code-ui packages automatically").action(async (cmdOpts) => {
|
|
547
548
|
const cwd = process.cwd();
|
|
549
|
+
const projectName = path.basename(cwd);
|
|
550
|
+
const pm = detectPackageManager(cwd);
|
|
548
551
|
const files = generateStarterFiles({
|
|
549
|
-
projectName
|
|
552
|
+
projectName,
|
|
550
553
|
appId: "touristappid",
|
|
551
554
|
primaryColor: cmdOpts.primary || "red",
|
|
552
555
|
iconCollection: cmdOpts.icons || "lucide",
|
|
553
|
-
prefix: cmdOpts.prefix || "c"
|
|
556
|
+
prefix: cmdOpts.prefix || "c",
|
|
557
|
+
pm
|
|
554
558
|
});
|
|
555
559
|
const cuiConfigPath = path.resolve(cwd, "cui.config.ts");
|
|
556
560
|
if (!fs.existsSync(cuiConfigPath)) {
|
|
@@ -576,7 +580,6 @@ program.command("init").description("Initialize Code UI configuration (cui.confi
|
|
|
576
580
|
logger.success(`Added ${pc.green("@import \"@code-id-labs/components\";")} to ${pc.green("src/app.css")}`);
|
|
577
581
|
}
|
|
578
582
|
}
|
|
579
|
-
const pm = detectPackageManager(cwd);
|
|
580
583
|
const pnpmWorkspacePath = path.resolve(cwd, "pnpm-workspace.yaml");
|
|
581
584
|
if (pm === "pnpm" && !fs.existsSync(pnpmWorkspacePath)) {
|
|
582
585
|
fs.writeFileSync(pnpmWorkspacePath, files["pnpm-workspace.yaml"] ?? "", "utf-8");
|