frontpl 0.2.0 → 0.3.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 CHANGED
@@ -28,6 +28,9 @@ Follow the prompts to choose:
28
28
 
29
29
  - Package manager (`npm`/`pnpm`/`yarn`/`bun`/`deno`)
30
30
  - Optional tooling: `oxlint`, `oxfmt`, `vitest`, `tsdown`
31
+
32
+ When `oxlint` is enabled, generated projects use `@kingsword/lint-config` via `oxlint.config.ts`.
33
+
31
34
  - Git init
32
35
  - GitHub Actions workflows:
33
36
  - CI only
@@ -42,9 +45,9 @@ Scaffold a new project into `./<name>` (or prompt for a name when omitted).
42
45
  Generated output includes (based on options):
43
46
 
44
47
  - `.editorconfig`, `.gitignore`, `.gitattributes`
45
- - `package.json` (+ scripts like `typecheck`, optional `lint`, `format:check`, `test`, `build`)
48
+ - `package.json` (+ scripts like optional `lint`, `format:check`, `test`, `build`)
46
49
  - `tsconfig.json`, `src/index.ts`
47
- - Optional configs: `.oxlintrc.json`, `.oxfmtrc.json`, `tsdown.config.ts`
50
+ - Optional configs: `oxlint.config.ts`, `.oxfmtrc.json`, `tsdown.config.ts`
48
51
  - Optional GitHub Actions workflows in `.github/workflows/`
49
52
 
50
53
  ### `frontpl ci`
@@ -82,8 +85,12 @@ frontpl generates workflows that call reusable workflows from `kingsword09/workf
82
85
 
83
86
  ```sh
84
87
  pnpm install
85
- pnpm run typecheck
88
+ pnpm run lint
86
89
  pnpm run build
87
90
  node dist/cli.mjs --help
88
91
  node dist/cli.mjs ci
89
92
  ```
93
+
94
+ ## Lint preset
95
+
96
+ This repository itself uses `@kingsword/lint-config` (see `oxlint.config.ts`).
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as runCi, t as runInit } from "./init-DXlH6jJs.mjs";
2
+ import { n as runCi, t as runInit } from "./init-CQKT_mPD.mjs";
3
3
  import bin from "tiny-bin";
4
4
 
5
5
  //#region src/cli.ts
package/dist/index.d.mts CHANGED
@@ -8,4 +8,39 @@ declare function runInit({
8
8
  nameArg?: string;
9
9
  }): Promise<void>;
10
10
  //#endregion
11
- export { runCi, runInit };
11
+ //#region src/lib/templates.d.ts
12
+ declare function oxlintConfigTemplate({
13
+ useVitest
14
+ }: {
15
+ useVitest: boolean;
16
+ }): string;
17
+ declare function packageJsonTemplate(opts: {
18
+ name: string;
19
+ packageManager: string;
20
+ typescriptVersion: string;
21
+ useOxlint: boolean;
22
+ oxlintVersion?: string;
23
+ oxlintTsgolintVersion?: string;
24
+ kingswordLintConfigVersion?: string;
25
+ useOxfmt: boolean;
26
+ oxfmtVersion?: string;
27
+ useVitest: boolean;
28
+ vitestVersion?: string;
29
+ useTsdown: boolean;
30
+ tsdownVersion?: string;
31
+ }): string;
32
+ declare function githubCliCiWorkflowTemplate(opts: {
33
+ packageManager: "npm" | "pnpm" | "yarn" | "bun" | "deno";
34
+ nodeVersion: number;
35
+ workingDirectory: string;
36
+ runLint: boolean;
37
+ runFormatCheck: boolean;
38
+ runTests: boolean;
39
+ installCommand?: string;
40
+ lintCommand?: string;
41
+ formatCheckCommand?: string;
42
+ testCommand?: string;
43
+ workflowsRef?: string;
44
+ }): string;
45
+ //#endregion
46
+ export { githubCliCiWorkflowTemplate, oxlintConfigTemplate, packageJsonTemplate, runCi, runInit };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { n as runCi, t as runInit } from "./init-DXlH6jJs.mjs";
1
+ import { a as packageJsonTemplate, i as oxlintConfigTemplate, n as runCi, r as githubCliCiWorkflowTemplate, t as runInit } from "./init-CQKT_mPD.mjs";
2
2
 
3
- export { runCi, runInit };
3
+ export { githubCliCiWorkflowTemplate, oxlintConfigTemplate, packageJsonTemplate, runCi, runInit };
@@ -88,13 +88,13 @@ function readmeTemplate(projectName) {
88
88
  ].join("\n");
89
89
  }
90
90
  function oxlintConfigTemplate({ useVitest }) {
91
- return JSON.stringify({
92
- $schema: "https://json.schemastore.org/oxlintrc.json",
93
- env: {
94
- browser: true,
95
- es2022: true
96
- }
97
- }, null, 2) + "\n";
91
+ return [
92
+ "import { defineConfig } from \"oxlint\";",
93
+ "import { oxlint } from \"@kingsword/lint-config/config\";",
94
+ "",
95
+ `export default defineConfig(oxlint({ profile: "lib", test: "${useVitest ? "vitest" : "none"}", level: "recommended" }));`,
96
+ ""
97
+ ].join("\n");
98
98
  }
99
99
  function oxfmtConfigTemplate() {
100
100
  return JSON.stringify({ $schema: "https://json.schemastore.org/oxfmtrc.json" }, null, 2) + "\n";
@@ -111,17 +111,12 @@ function tsdownConfigTemplate() {
111
111
  ].join("\n");
112
112
  }
113
113
  function packageJsonTemplate(opts) {
114
- const scripts = { typecheck: "tsc --noEmit" };
114
+ const scripts = {};
115
115
  if (opts.useOxlint) {
116
- const oxlintCmd = [
117
- "oxlint",
118
- opts.useVitest ? "--vitest-plugin" : void 0,
119
- "--type-aware",
120
- "--type-check"
121
- ].filter(Boolean).join(" ");
116
+ const oxlintCmd = "oxlint --type-aware --type-check";
122
117
  scripts.lint = oxlintCmd;
123
118
  scripts["lint:fix"] = `${oxlintCmd} --fix`;
124
- }
119
+ } else scripts.typecheck = "tsc --noEmit";
125
120
  if (opts.useOxfmt) {
126
121
  scripts.format = "oxfmt";
127
122
  scripts["format:check"] = "oxfmt --check";
@@ -134,6 +129,7 @@ function packageJsonTemplate(opts) {
134
129
  if (opts.useOxlint) {
135
130
  if (opts.oxlintVersion) devDependencies.oxlint = opts.oxlintVersion;
136
131
  if (opts.oxlintTsgolintVersion) devDependencies["oxlint-tsgolint"] = opts.oxlintTsgolintVersion;
132
+ if (opts.kingswordLintConfigVersion) devDependencies["@kingsword/lint-config"] = opts.kingswordLintConfigVersion;
137
133
  }
138
134
  if (opts.useOxfmt && opts.oxfmtVersion) devDependencies.oxfmt = opts.oxfmtVersion;
139
135
  if (opts.useVitest && opts.vitestVersion) devDependencies.vitest = opts.vitestVersion;
@@ -527,9 +523,9 @@ async function resolveCiCommands(rootDir, workingDirectory, packageManager) {
527
523
  runLint,
528
524
  runFormatCheck,
529
525
  runTests,
530
- lintCommand: runLint && !hasLint ? await promptCommand("Lint command", pmRun(packageManager, "lint")) : void 0,
531
- formatCheckCommand: runFormatCheck && !hasFormatCheck ? hasFmtCheck ? pmRun(packageManager, "fmt:check") : await promptCommand("Format check command", pmRun(packageManager, "format:check")) : void 0,
532
- testCommand: runTests && !hasTest ? await promptCommand("Test command", pmRun(packageManager, "test")) : void 0
526
+ lintCommand: runLint && hasLint ? pmRun$1(packageManager, "lint") : runLint ? await promptCommand("Lint command", pmRun$1(packageManager, "lint")) : void 0,
527
+ formatCheckCommand: runFormatCheck && hasFormatCheck ? pmRun$1(packageManager, "format:check") : runFormatCheck && hasFmtCheck ? pmRun$1(packageManager, "fmt:check") : runFormatCheck ? await promptCommand("Format check command", pmRun$1(packageManager, "format:check")) : void 0,
528
+ testCommand: runTests && hasTest ? pmRun$1(packageManager, "test") : runTests ? await promptCommand("Test command", pmRun$1(packageManager, "test")) : void 0
533
529
  };
534
530
  }
535
531
  async function promptCommand(message, initialValue) {
@@ -541,7 +537,7 @@ async function promptCommand(message, initialValue) {
541
537
  if (isCancel(value)) return abort();
542
538
  return String(value).trim();
543
539
  }
544
- function pmRun(pm, script) {
540
+ function pmRun$1(pm, script) {
545
541
  switch (pm) {
546
542
  case "npm": return `npm run ${script}`;
547
543
  case "pnpm": return `pnpm run ${script}`;
@@ -629,6 +625,15 @@ function resolveCommand(command) {
629
625
 
630
626
  //#endregion
631
627
  //#region src/commands/init.ts
628
+ function pmRun(pm, script) {
629
+ switch (pm) {
630
+ case "npm": return `npm run ${script}`;
631
+ case "pnpm": return `pnpm run ${script}`;
632
+ case "yarn": return `yarn ${script}`;
633
+ case "bun": return `bun run ${script}`;
634
+ case "deno": return script;
635
+ }
636
+ }
632
637
  async function runInit({ nameArg }) {
633
638
  intro("frontpl");
634
639
  const projectName = await text({
@@ -670,7 +675,7 @@ async function runInit({ nameArg }) {
670
675
  }) : false;
671
676
  if (isCancel(pnpmWorkspace)) return onCancel();
672
677
  const useOxlint = await confirm({
673
- message: "Enable oxlint (type-aware + type-check via tsgolint)?",
678
+ message: "Enable oxlint (@kingsword/lint-config preset)?",
674
679
  initialValue: true
675
680
  });
676
681
  if (isCancel(useOxlint)) return onCancel();
@@ -775,6 +780,7 @@ async function runInit({ nameArg }) {
775
780
  useOxlint,
776
781
  oxlintVersion: "latest",
777
782
  oxlintTsgolintVersion: "latest",
783
+ kingswordLintConfigVersion: "^0.1.1",
778
784
  useOxfmt,
779
785
  oxfmtVersion: "latest",
780
786
  useVitest,
@@ -783,20 +789,26 @@ async function runInit({ nameArg }) {
783
789
  tsdownVersion: "latest"
784
790
  }))
785
791
  ]);
786
- if (useOxlint) await writeText(path.join(pkgDir, ".oxlintrc.json"), oxlintConfigTemplate({ useVitest }));
792
+ if (useOxlint) await writeText(path.join(pkgDir, "oxlint.config.ts"), oxlintConfigTemplate({ useVitest }));
787
793
  if (useOxfmt) await writeText(path.join(pkgDir, ".oxfmtrc.json"), oxfmtConfigTemplate());
788
794
  if (useVitest) await writeText(path.join(pkgDir, "src/index.test.ts"), srcVitestTemplate());
789
795
  if (useTsdown) await writeText(path.join(pkgDir, "tsdown.config.ts"), tsdownConfigTemplate());
790
796
  if (packageManager === "deno") await writeText(path.join(rootDir, "deno.json"), JSON.stringify({ nodeModulesDir: "auto" }, null, 2) + "\n");
791
797
  if (githubActions !== "none") {
792
798
  const workingDirectory = pnpmWorkspace ? path.posix.join("packages", projectName) : ".";
799
+ const lintCommand = useOxlint && packageManager !== "deno" ? pmRun(packageManager, "lint") : void 0;
800
+ const formatCheckCommand = useOxfmt && packageManager !== "deno" ? pmRun(packageManager, "format:check") : void 0;
801
+ const testCommand = useVitest && packageManager !== "deno" ? pmRun(packageManager, "test") : void 0;
793
802
  await writeText(path.join(rootDir, ".github/workflows/ci.yml"), githubCliCiWorkflowTemplate({
794
803
  packageManager,
795
804
  nodeVersion: 22,
796
805
  workingDirectory,
797
806
  runLint: useOxlint,
798
807
  runFormatCheck: useOxfmt,
799
- runTests: useVitest
808
+ runTests: useVitest,
809
+ lintCommand,
810
+ formatCheckCommand,
811
+ testCommand
800
812
  }));
801
813
  }
802
814
  if (githubActions === "ci+release") {
@@ -834,13 +846,13 @@ function onCancel() {
834
846
  }
835
847
  function nextStepHint(pm) {
836
848
  switch (pm) {
837
- case "npm": return "npm run typecheck";
838
- case "pnpm": return "pnpm run typecheck";
839
- case "yarn": return "yarn typecheck";
840
- case "bun": return "bun run typecheck";
841
- case "deno": return "deno task typecheck # (or run the package.json scripts with your preferred runner)";
849
+ case "npm": return "npm run lint";
850
+ case "pnpm": return "pnpm run lint";
851
+ case "yarn": return "yarn lint";
852
+ case "bun": return "bun run lint";
853
+ case "deno": return "deno task lint # (or run the package.json scripts with your preferred runner)";
842
854
  }
843
855
  }
844
856
 
845
857
  //#endregion
846
- export { runCi as n, runInit as t };
858
+ export { packageJsonTemplate as a, oxlintConfigTemplate as i, runCi as n, githubCliCiWorkflowTemplate as r, runInit as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frontpl",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Interactive CLI to scaffold standardized frontend project templates.",
5
5
  "keywords": [
6
6
  "cli",
@@ -53,9 +53,10 @@
53
53
  "tiny-bin": "^1.11.3"
54
54
  },
55
55
  "devDependencies": {
56
+ "@kingsword/lint-config": "^0.1.1",
56
57
  "@types/node": "^25.0.10",
57
- "oxfmt": "^0.26.0",
58
- "oxlint": "^1.41.0",
58
+ "oxfmt": "^0.28.0",
59
+ "oxlint": "^1.43.0",
59
60
  "oxlint-tsgolint": "^0.11.1",
60
61
  "tsdown": "^0.20.1",
61
62
  "typescript": "^5.9.3"