create-app-ui 1.0.1 → 1.0.2
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/src/generator.js +5 -4
- package/dist/src/utils.js +11 -0
- package/package.json +1 -1
package/dist/src/generator.js
CHANGED
|
@@ -7,7 +7,7 @@ import { askOverwriteConfirmation, askQuestions } from "./prompts.js";
|
|
|
7
7
|
import { initializeGit, installDependencies } from "./installer.js";
|
|
8
8
|
import { replacePlaceholders } from "./replace-placeholders.js";
|
|
9
9
|
import { resolveBoilerplateDir, resolveTemplateDir } from "./paths.js";
|
|
10
|
-
import { copyDirectoryContents, isValidAppName, resolveTargetDir, toTitleCase } from "./utils.js";
|
|
10
|
+
import { copyDirectoryContents, createNodeModulesFilter, isValidAppName, resolveTargetDir, toTitleCase, } from "./utils.js";
|
|
11
11
|
export async function runCli(args) {
|
|
12
12
|
const parsed = parseArgv(args);
|
|
13
13
|
const appNameArg = parsed.positional[0]?.trim();
|
|
@@ -35,14 +35,15 @@ export async function runCli(args) {
|
|
|
35
35
|
if (!(await fs.pathExists(templateDir))) {
|
|
36
36
|
throw new Error(`Template not found: ${templateDir}`);
|
|
37
37
|
}
|
|
38
|
-
const
|
|
38
|
+
const skipBoilerplateNodeModules = createNodeModulesFilter(boilerplateDir);
|
|
39
|
+
const skipTemplateNodeModules = createNodeModulesFilter(templateDir);
|
|
39
40
|
const baseSpinner = ora("Copying shared boilerplate...").start();
|
|
40
|
-
await copyDirectoryContents(boilerplateDir, targetDir, { filter:
|
|
41
|
+
await copyDirectoryContents(boilerplateDir, targetDir, { filter: skipBoilerplateNodeModules });
|
|
41
42
|
baseSpinner.succeed("Boilerplate copied.");
|
|
42
43
|
const templateSpinner = ora(`Applying "${answers.template}" template...`).start();
|
|
43
44
|
await copyDirectoryContents(templateDir, targetDir, {
|
|
44
45
|
filter: (src) => {
|
|
45
|
-
if (!
|
|
46
|
+
if (!skipTemplateNodeModules(src)) {
|
|
46
47
|
return false;
|
|
47
48
|
}
|
|
48
49
|
// IDE-only overlay config; generated apps keep boilerplate tsconfig.* only.
|
package/dist/src/utils.js
CHANGED
|
@@ -5,6 +5,17 @@ const APP_NAME_REGEX = /^(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$
|
|
|
5
5
|
* Copies the contents of `srcDir` into `destDir` (not `srcDir` as a nested folder).
|
|
6
6
|
* fs.copy(dir, dest) alone would create dest/<basename(srcDir)>/.
|
|
7
7
|
*/
|
|
8
|
+
/** Skip only `node_modules` inside `rootDir`, not `node_modules` in the absolute install path (npx/npm). */
|
|
9
|
+
export function createNodeModulesFilter(rootDir) {
|
|
10
|
+
return (src) => {
|
|
11
|
+
const relativePath = path.relative(rootDir, src);
|
|
12
|
+
if (!relativePath || relativePath.startsWith("..")) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
const segments = relativePath.split(path.sep).filter(Boolean);
|
|
16
|
+
return !segments.includes("node_modules");
|
|
17
|
+
};
|
|
18
|
+
}
|
|
8
19
|
export async function copyDirectoryContents(srcDir, destDir, options) {
|
|
9
20
|
const filter = options?.filter;
|
|
10
21
|
await fs.ensureDir(destDir);
|