create-wakii-stack 0.1.2 → 0.1.3

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.
Files changed (2) hide show
  1. package/dist/index.js +33 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -81,7 +81,7 @@ function resolveOptions(options, ctx) {
81
81
  }
82
82
 
83
83
  // src/scaffold.ts
84
- import { mkdir, readFile, readdir, rm, writeFile } from "fs/promises";
84
+ import { chmod, mkdir, readFile, readdir, rm, stat, writeFile } from "fs/promises";
85
85
  import { existsSync } from "fs";
86
86
  import { dirname, join, resolve } from "path";
87
87
  import { fileURLToPath } from "url";
@@ -228,6 +228,14 @@ async function scaffold(input) {
228
228
  await copyTree(templateRoot, dest, { stackName: selection.appName, files });
229
229
  const allServices = Object.keys(manifest.services);
230
230
  const pruned = allServices.filter((s) => !selection.services.includes(s));
231
+ const ALWAYS_PRUNE = ["app/create-wakii-app", "app/create-wakii-stack", "app/starter-templates", "app/stack-template", "app/spike"];
232
+ for (const relPath of ALWAYS_PRUNE) {
233
+ const target = join(dest, relPath);
234
+ if (existsSync(target)) {
235
+ await rm(target, { recursive: true, force: true });
236
+ log2?.(`Pruned tooling: ${relPath}`);
237
+ }
238
+ }
231
239
  for (const name of pruned) {
232
240
  for (const rawPath of manifest.services[name].paths ?? []) {
233
241
  const relPath = rawPath.endsWith("/**") ? rawPath.slice(0, -3) : rawPath;
@@ -263,8 +271,32 @@ async function scaffold(input) {
263
271
  }
264
272
  }
265
273
  await writeFile(join(dest, "README.md"), renderReadme(manifest, selection));
274
+ const execFixed = await fixExecutableBits(dest);
275
+ if (execFixed > 0) log2?.(`chmod +x: ${execFixed} script`);
266
276
  return { files: [...files.map((f) => f.slice(dest.length + 1)), "README.md"], prunedServices: pruned };
267
277
  }
278
+ async function fixExecutableBits(root) {
279
+ let count = 0;
280
+ const walk = async (dir) => {
281
+ for (const entry of await readdir(dir, { withFileTypes: true })) {
282
+ if (entry.name === "node_modules" || entry.name === ".git") continue;
283
+ const full = join(dir, entry.name);
284
+ if (entry.isDirectory()) {
285
+ await walk(full);
286
+ continue;
287
+ }
288
+ if (/\.(sh)$/.test(entry.name) || entry.name === "mvnw" || entry.name === "gradlew") {
289
+ const st = await stat(full);
290
+ if (!(st.mode & 73)) {
291
+ await chmod(full, st.mode | 493);
292
+ count += 1;
293
+ }
294
+ }
295
+ }
296
+ };
297
+ await walk(root);
298
+ return count;
299
+ }
268
300
 
269
301
  // src/index.ts
270
302
  var USAGE = `create-wakii-stack \u2014 scaffold full-stack FE+BE (Hybrid C: full-copy + prune)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-wakii-stack",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "CLI scaffold full-stack (FE+BE) dùng @wakii/ui-kit — full-copy + prune theo manifest (spec Hybrid C)",
6
6
  "bin": {