create-app-ui 1.0.0 → 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/README.md CHANGED
@@ -68,18 +68,22 @@ cd ui-platform/create-app-ui
68
68
  npm run pack:check
69
69
  ```
70
70
 
71
- 3. Publish (first time or new version):
71
+ 3. Publish from the **ui-platform** root (avoids workspace E404 errors):
72
72
 
73
73
  ```bash
74
- npm publish
74
+ cd ui-platform
75
+ npm publish -w create-app-ui --otp=123456
75
76
  ```
76
77
 
77
- Scoped public package:
78
+ Or from the package folder:
78
79
 
79
80
  ```bash
80
- npm publish --access public
81
+ cd ui-platform/create-app-ui
82
+ npm run publish:npm -- --otp=123456
81
83
  ```
82
84
 
85
+ Use your current 2FA code instead of `123456`. Confirm you are logged in as the package owner (`npm whoami` → should match [maintainers on npm](https://www.npmjs.com/package/create-app-ui)).
86
+
83
87
  4. Bump version for updates:
84
88
 
85
89
  ```bash
@@ -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 { 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,16 +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 skipBoilerplateNodeModules = createNodeModulesFilter(boilerplateDir);
39
+ const skipTemplateNodeModules = createNodeModulesFilter(templateDir);
38
40
  const baseSpinner = ora("Copying shared boilerplate...").start();
39
- await fs.copy(boilerplateDir, targetDir, {
40
- filter: (src) => !src.includes(`${path.sep}node_modules${path.sep}`),
41
- });
41
+ await copyDirectoryContents(boilerplateDir, targetDir, { filter: skipBoilerplateNodeModules });
42
42
  baseSpinner.succeed("Boilerplate copied.");
43
43
  const templateSpinner = ora(`Applying "${answers.template}" template...`).start();
44
- await fs.copy(templateDir, targetDir, {
45
- overwrite: true,
44
+ await copyDirectoryContents(templateDir, targetDir, {
46
45
  filter: (src) => {
47
- if (src.includes(`${path.sep}node_modules${path.sep}`)) {
46
+ if (!skipTemplateNodeModules(src)) {
48
47
  return false;
49
48
  }
50
49
  // IDE-only overlay config; generated apps keep boilerplate tsconfig.* only.
@@ -56,13 +55,16 @@ export async function runCli(args) {
56
55
  },
57
56
  });
58
57
  templateSpinner.succeed("Template applied.");
58
+ const packageJsonPath = path.join(targetDir, "package.json");
59
+ if (!(await fs.pathExists(packageJsonPath))) {
60
+ throw new Error(`Scaffold incomplete: missing package.json in ${targetDir}. Try upgrading create-app-ui: npx create-app-ui@latest`);
61
+ }
59
62
  const title = toTitleCase(answers.appName.split("/").pop() ?? answers.appName);
60
63
  await replacePlaceholders(targetDir, {
61
64
  "__APP_NAME__": answers.appName,
62
65
  "__APP_TITLE__": title,
63
66
  "__COMPANY_NAME__": answers.companyName,
64
67
  });
65
- const packageJsonPath = path.join(targetDir, "package.json");
66
68
  const packageJson = await fs.readJson(packageJsonPath);
67
69
  packageJson.name = answers.appName;
68
70
  await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
package/dist/src/utils.js CHANGED
@@ -1,5 +1,38 @@
1
1
  import path from "node:path";
2
+ import fs from "fs-extra";
2
3
  const APP_NAME_REGEX = /^(?:@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
4
+ /**
5
+ * Copies the contents of `srcDir` into `destDir` (not `srcDir` as a nested folder).
6
+ * fs.copy(dir, dest) alone would create dest/<basename(srcDir)>/.
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
+ }
19
+ export async function copyDirectoryContents(srcDir, destDir, options) {
20
+ const filter = options?.filter;
21
+ await fs.ensureDir(destDir);
22
+ const entries = await fs.readdir(srcDir);
23
+ for (const entry of entries) {
24
+ const srcPath = path.join(srcDir, entry);
25
+ if (filter && !filter(srcPath)) {
26
+ continue;
27
+ }
28
+ const destPath = path.join(destDir, entry);
29
+ await fs.copy(srcPath, destPath, {
30
+ overwrite: true,
31
+ errorOnExist: false,
32
+ filter: filter ? (src) => filter(src) : undefined,
33
+ });
34
+ }
35
+ }
3
36
  export function isValidAppName(name) {
4
37
  return APP_NAME_REGEX.test(name);
5
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-app-ui",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Scaffold enterprise React admin apps (Vite, TypeScript, shadcn-style UI) from the Omobio UI platform",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -28,7 +28,11 @@
28
28
  },
29
29
  "homepage": "https://github.com/malikmanujaya/omobio-common-gui/tree/main/ui-platform/create-app-ui#readme",
30
30
  "bin": {
31
- "create-app-ui": "./dist/bin/index.js"
31
+ "create-app-ui": "dist/bin/index.js"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public",
35
+ "registry": "https://registry.npmjs.org/"
32
36
  },
33
37
  "files": [
34
38
  "dist",
@@ -43,6 +47,7 @@
43
47
  "prepublishOnly": "npm run build && npm run prepare-publish",
44
48
  "prepack": "npm run build && npm run prepare-publish",
45
49
  "pack:check": "npm run prepack && npm pack --dry-run",
50
+ "publish:npm": "npm publish --registry https://registry.npmjs.org/",
46
51
  "dev:watch": "tsx watch bin/index.ts",
47
52
  "start": "tsx bin/index.ts"
48
53
  },