create-codebase-snapshot 0.0.0-stage → 2.1.1
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 +25 -2
- package/index.mjs +72 -0
- package/package.json +31 -4
package/README.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# create-codebase-snapshot
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Sets up [`@ankurhalder/codebase-snapshot`](https://www.npmjs.com/package/@ankurhalder/codebase-snapshot)
|
|
4
|
+
in the current repository.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm create codebase-snapshot
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
It detects the project type, asks a handful of questions with sensible defaults,
|
|
11
|
+
and writes a `snapshot.config.mjs` that lists **every setting at its default** —
|
|
12
|
+
so the config doubles as the documentation.
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm create codebase-snapshot -- --preset react-vite --yes
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
| Option | Effect |
|
|
19
|
+
| :--- | :--- |
|
|
20
|
+
| `--preset <name>` | Force a project preset instead of detecting one |
|
|
21
|
+
| `--yes` | Accept every default without prompting |
|
|
22
|
+
| `--minimal` | Write only the settings that differ from defaults |
|
|
23
|
+
| `--force` | Overwrite an existing config |
|
|
24
|
+
|
|
25
|
+
This package is a shim: the wizard itself lives in the main package, so
|
|
26
|
+
`npx @ankurhalder/codebase-snapshot init` does exactly the same thing.
|
package/index.mjs
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { PromptCancelled, runInit } from "@ankurhalder/codebase-snapshot";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `npm create codebase-snapshot`
|
|
6
|
+
*
|
|
7
|
+
* A thin shim over the same wizard the main package exposes, so there is exactly
|
|
8
|
+
* one prompt implementation to keep working. Everything it does is available as
|
|
9
|
+
* `npx @ankurhalder/codebase-snapshot init`; this entry point only exists because
|
|
10
|
+
* `npm create <x>` is the convention developers reach for first.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const argv = process.argv.slice(2);
|
|
14
|
+
|
|
15
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
16
|
+
process.stderr.write(
|
|
17
|
+
[
|
|
18
|
+
"create-codebase-snapshot",
|
|
19
|
+
"",
|
|
20
|
+
" Sets up @ankurhalder/codebase-snapshot in the current directory.",
|
|
21
|
+
"",
|
|
22
|
+
" Usage:",
|
|
23
|
+
" npm create codebase-snapshot",
|
|
24
|
+
"",
|
|
25
|
+
" Options:",
|
|
26
|
+
" --preset <name> Force a project preset instead of detecting one",
|
|
27
|
+
" --yes Accept every default without prompting",
|
|
28
|
+
" --minimal Write only the settings that differ from defaults",
|
|
29
|
+
" --force Overwrite an existing config",
|
|
30
|
+
"",
|
|
31
|
+
].join("\n")
|
|
32
|
+
);
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const takeValue = (flag) => {
|
|
37
|
+
const index = argv.indexOf(flag);
|
|
38
|
+
if (index === -1) return undefined;
|
|
39
|
+
const value = argv[index + 1];
|
|
40
|
+
return value && !value.startsWith("-") ? value : undefined;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
const result = await runInit({
|
|
45
|
+
cwd: process.cwd(),
|
|
46
|
+
preset: takeValue("--preset"),
|
|
47
|
+
yes: argv.includes("--yes"),
|
|
48
|
+
minimal: argv.includes("--minimal"),
|
|
49
|
+
force: argv.includes("--force"),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (!result.written) {
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
process.stderr.write(`\n✅ Created ${result.configPath} (preset: ${result.preset})\n`);
|
|
57
|
+
if (result.scripts.length > 0) {
|
|
58
|
+
process.stderr.write(` Added npm scripts: ${result.scripts.join(", ")}\n`);
|
|
59
|
+
}
|
|
60
|
+
if (result.gitignoreEntries.length > 0) {
|
|
61
|
+
process.stderr.write(` Added to .gitignore: ${result.gitignoreEntries.join(", ")}\n`);
|
|
62
|
+
}
|
|
63
|
+
for (const note of result.notes) process.stderr.write(` ⚠ ${note}\n`);
|
|
64
|
+
process.stderr.write("\n Next: npm run snapshot\n\n");
|
|
65
|
+
} catch (err) {
|
|
66
|
+
if (err instanceof PromptCancelled) {
|
|
67
|
+
process.stderr.write("\n❌ Cancelled.\n");
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
process.stderr.write(`\n❌ ${err instanceof Error ? err.message : String(err)}\n`);
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-codebase-snapshot",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.1.1",
|
|
4
|
+
"description": "Set up @ankurhalder/codebase-snapshot in a repository",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Ankur Halder <ankur.halder12345@gmail.com>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/ankurhalder/codebase-snapshot.git",
|
|
10
|
+
"directory": "packages/create"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/ankurhalder/codebase-snapshot#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/ankurhalder/codebase-snapshot/issues"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"bin": {
|
|
18
|
+
"create-codebase-snapshot": "./index.mjs"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"index.mjs",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@ankurhalder/codebase-snapshot": "^2.1.1"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18.0.0"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
}
|
|
33
|
+
}
|