create-chanom-app 0.0.0 → 0.2.0
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 +1 -0
- package/dist/index.js +46 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -71,6 +71,7 @@ A minimal Vite + React + TS app wired to the chanom shared configs:
|
|
|
71
71
|
- `oxlint.config.ts` / `oxfmt.config.ts` - re-exporting the [`@chanom/dev-config`](../dev-config) presets
|
|
72
72
|
- `vitest.config.ts` and a sample `src/app.test.tsx`
|
|
73
73
|
- `src/` - `main.tsx`, `app.tsx`, `index.css`, and type declarations
|
|
74
|
+
- `.vscode/settings.json` and `.vscode/extensions.json` - editor settings that run oxfmt formatting and oxlint fixes on save through the [oxc extension](https://marketplace.visualstudio.com/items?itemName=oxc.oxc-vscode), which is recommended so teammates are prompted to install it
|
|
74
75
|
- `index.html`, `.gitignore`, and a starter `README.md`
|
|
75
76
|
|
|
76
77
|
With the **commit-hooks** topping, it also adds husky, lint-staged, and commitlint as dev dependencies plus their config files (`.husky/pre-commit`, `.husky/commit-msg`, `.lintstagedrc.json`, `.commitlintrc.json`). The hooks materialize on the first install via the generated `prepare: "husky"` script.
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,43 @@ function resolvePm(hints) {
|
|
|
39
39
|
return parsePmField(hints.packageManagerField) ?? parsePmUserAgent(hints.userAgent) ?? hints.fallback ?? "pnpm";
|
|
40
40
|
}
|
|
41
41
|
//#endregion
|
|
42
|
+
//#region ../internal/src/domain/vscode.ts
|
|
43
|
+
/** Keys VS Code reads as a per-language override, e.g. `[typescript]`. */
|
|
44
|
+
const LANGUAGES = [
|
|
45
|
+
"markdown",
|
|
46
|
+
"json",
|
|
47
|
+
"typescriptreact",
|
|
48
|
+
"typescript",
|
|
49
|
+
"javascript"
|
|
50
|
+
];
|
|
51
|
+
const OXC_FORMATTER = "oxc.oxc-vscode";
|
|
52
|
+
/** The extensions a chanom project recommends; unioned into an existing list. */
|
|
53
|
+
const RECOMMENDED_EXTENSIONS = [OXC_FORMATTER];
|
|
54
|
+
/**
|
|
55
|
+
* The VS Code settings chanom contributes. Every value is portable across
|
|
56
|
+
* projects - repo-specific entries (`cSpell.words`, `git.*`) are deliberately
|
|
57
|
+
* excluded so this can be dropped into any project without carrying chanom's
|
|
58
|
+
* own choices.
|
|
59
|
+
*
|
|
60
|
+
* `editor.formatOnSave` is false on purpose: formatting runs through the oxc
|
|
61
|
+
* code action instead, so formatting and lint fixes apply in one pass rather
|
|
62
|
+
* than racing each other.
|
|
63
|
+
*/
|
|
64
|
+
function chanomSettings(oxfmtConfigPath) {
|
|
65
|
+
return {
|
|
66
|
+
"editor.defaultFormatter": OXC_FORMATTER,
|
|
67
|
+
"editor.formatOnSave": false,
|
|
68
|
+
"editor.codeActionsOnSave": {
|
|
69
|
+
"source.format.oxc": "always",
|
|
70
|
+
"source.fixAll.oxc": "always",
|
|
71
|
+
"source.removeUnusedImports": "always"
|
|
72
|
+
},
|
|
73
|
+
"oxc.fmt.configPath": oxfmtConfigPath,
|
|
74
|
+
"oxc.typeAware": true,
|
|
75
|
+
...Object.fromEntries(LANGUAGES.map((language) => [`[${language}]`, { "editor.defaultFormatter": OXC_FORMATTER }]))
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
42
79
|
//#region ../internal/src/services/command-runner.ts
|
|
43
80
|
const collectText = (stream) => stream.pipe(Stream.decodeText(), Stream.mkString);
|
|
44
81
|
/**
|
|
@@ -195,7 +232,7 @@ const depVersions = {
|
|
|
195
232
|
"@chanom/vite-config": "0.1.0"
|
|
196
233
|
};
|
|
197
234
|
/** This package's own version, for `--version`. */
|
|
198
|
-
const pkgVersion = "0.
|
|
235
|
+
const pkgVersion = "0.2.0";
|
|
199
236
|
//#endregion
|
|
200
237
|
//#region src/domain/args.ts
|
|
201
238
|
const PACKAGE_MANAGERS = [
|
|
@@ -515,6 +552,7 @@ const TEMPLATE_FILES = [
|
|
|
515
552
|
];
|
|
516
553
|
//#endregion
|
|
517
554
|
//#region src/toppings.ts
|
|
555
|
+
const asJson = (value) => JSON.stringify(value, null, 2) + "\n";
|
|
518
556
|
/**
|
|
519
557
|
* The always-present baseline: a minimal Vite + React + TS app wired to the
|
|
520
558
|
* chanom shared configs. Its static source files ship as verbatim templates;
|
|
@@ -553,7 +591,13 @@ const baseline = {
|
|
|
553
591
|
},
|
|
554
592
|
viteImports: ["import react from '@vitejs/plugin-react';"],
|
|
555
593
|
vitePlugins: ["react()"],
|
|
556
|
-
files: [
|
|
594
|
+
files: [{
|
|
595
|
+
path: ".vscode/settings.json",
|
|
596
|
+
contents: asJson(chanomSettings("oxfmt.config.ts"))
|
|
597
|
+
}, {
|
|
598
|
+
path: ".vscode/extensions.json",
|
|
599
|
+
contents: asJson({ recommendations: RECOMMENDED_EXTENSIONS })
|
|
600
|
+
}]
|
|
557
601
|
};
|
|
558
602
|
const LINT_STAGED_CONFIG = {
|
|
559
603
|
"**/*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}": ["oxlint --fix --no-error-on-unmatched-pattern"],
|