frontpl 0.4.0 → 0.4.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 +8 -0
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +13 -1
- package/dist/index.mjs +2 -2
- package/dist/{oxfmt-Bgtl3zwv.mjs → oxfmt-DlwbhnpJ.mjs} +49 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ frontpl init my-frontend
|
|
|
27
27
|
Follow the prompts to choose:
|
|
28
28
|
|
|
29
29
|
- Package manager (`npm`/`pnpm`/`yarn`/`bun`/`deno`)
|
|
30
|
+
- Optional `pnpm workspace` mode (monorepo skeleton)
|
|
30
31
|
- Optional tooling: `oxlint`, `oxfmt`, `vitest`, `tsdown`
|
|
31
32
|
|
|
32
33
|
When `oxlint` is enabled, generated projects use `@kingsword/lint-config` via `oxlint.config.ts`.
|
|
@@ -53,6 +54,12 @@ Generated output includes (based on options):
|
|
|
53
54
|
- Optional configs: `oxlint.config.ts`, `.oxfmtrc.json`, `tsdown.config.ts`
|
|
54
55
|
- Optional GitHub Actions workflows in `.github/workflows/`
|
|
55
56
|
|
|
57
|
+
When `pnpm workspace mode` is enabled:
|
|
58
|
+
|
|
59
|
+
- Root contains `pnpm-workspace.yaml` and the workspace `package.json`
|
|
60
|
+
- `oxlint`/`oxfmt` scripts, dependencies, and config files are generated at the workspace root
|
|
61
|
+
- App/library package is scaffolded under `packages/<name>/` with its own `package.json`, `src`, and `tsconfig.json`
|
|
62
|
+
|
|
56
63
|
### `frontpl ci`
|
|
57
64
|
|
|
58
65
|
Add or update CI/Release workflows for an existing project (run it in your repo root).
|
|
@@ -138,6 +145,7 @@ When CI workflows are enabled, frontpl can also generate `.github/dependabot.yml
|
|
|
138
145
|
- Keeps `github-actions` updates enabled
|
|
139
146
|
- Adds grouped dependencies updates (`groups.dependencies`)
|
|
140
147
|
- Uses the selected `workingDirectory` (`.` -> `/`, monorepo package -> `/packages/<name>`)
|
|
148
|
+
- In `frontpl init` + `pnpm workspace mode`, default `workingDirectory` is workspace root (`/`)
|
|
141
149
|
- Maps JavaScript package managers (`npm`/`pnpm`/`yarn`/`bun`) to Dependabot `package-ecosystem: "npm"`
|
|
142
150
|
|
|
143
151
|
## Development
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as runCi, n as runOxlint, r as runInit, t as runOxfmt } from "./oxfmt-
|
|
2
|
+
import { a as runCi, n as runOxlint, r as runInit, t as runOxfmt } from "./oxfmt-DlwbhnpJ.mjs";
|
|
3
3
|
import bin from "tiny-bin";
|
|
4
4
|
|
|
5
5
|
//#region src/cli.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -46,6 +46,18 @@ declare function packageJsonTemplate(opts: {
|
|
|
46
46
|
useTsdown: boolean;
|
|
47
47
|
tsdownVersion?: string;
|
|
48
48
|
}): string;
|
|
49
|
+
declare function workspaceRootPackageJsonTemplate(opts: {
|
|
50
|
+
name: string;
|
|
51
|
+
packageManager: string;
|
|
52
|
+
useOxlint: boolean;
|
|
53
|
+
oxlintVersion?: string;
|
|
54
|
+
oxlintTsgolintVersion?: string;
|
|
55
|
+
kingswordLintConfigVersion?: string;
|
|
56
|
+
useOxfmt: boolean;
|
|
57
|
+
oxfmtVersion?: string;
|
|
58
|
+
useVitest: boolean;
|
|
59
|
+
useTsdown: boolean;
|
|
60
|
+
}): string;
|
|
49
61
|
declare function githubCliCiWorkflowTemplate(opts: {
|
|
50
62
|
packageManager: "npm" | "pnpm" | "yarn" | "bun" | "deno";
|
|
51
63
|
nodeVersion: number;
|
|
@@ -65,4 +77,4 @@ declare function githubDependabotTemplate(opts: {
|
|
|
65
77
|
workingDirectory: string;
|
|
66
78
|
}): string;
|
|
67
79
|
//#endregion
|
|
68
|
-
export { githubCliCiWorkflowTemplate, githubDependabotTemplate, oxlintConfigTemplate, packageJsonTemplate, runCi, runInit, runOxfmt, runOxlint, validateProjectName };
|
|
80
|
+
export { githubCliCiWorkflowTemplate, githubDependabotTemplate, oxlintConfigTemplate, packageJsonTemplate, runCi, runInit, runOxfmt, runOxlint, validateProjectName, workspaceRootPackageJsonTemplate };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as runCi, c as oxlintConfigTemplate, i as validateProjectName, l as packageJsonTemplate, n as runOxlint, o as githubCliCiWorkflowTemplate, r as runInit, s as githubDependabotTemplate, t as runOxfmt } from "./oxfmt-
|
|
1
|
+
import { a as runCi, c as oxlintConfigTemplate, i as validateProjectName, l as packageJsonTemplate, n as runOxlint, o as githubCliCiWorkflowTemplate, r as runInit, s as githubDependabotTemplate, t as runOxfmt, u as workspaceRootPackageJsonTemplate } from "./oxfmt-DlwbhnpJ.mjs";
|
|
2
2
|
|
|
3
|
-
export { githubCliCiWorkflowTemplate, githubDependabotTemplate, oxlintConfigTemplate, packageJsonTemplate, runCi, runInit, runOxfmt, runOxlint, validateProjectName };
|
|
3
|
+
export { githubCliCiWorkflowTemplate, githubDependabotTemplate, oxlintConfigTemplate, packageJsonTemplate, runCi, runInit, runOxfmt, runOxlint, validateProjectName, workspaceRootPackageJsonTemplate };
|
|
@@ -152,28 +152,35 @@ function tsdownConfigTemplate() {
|
|
|
152
152
|
""
|
|
153
153
|
].join("\n");
|
|
154
154
|
}
|
|
155
|
-
function
|
|
156
|
-
const scripts = {};
|
|
155
|
+
function applyLintAndFormatScripts(scripts, opts) {
|
|
157
156
|
if (opts.useOxlint) {
|
|
158
157
|
const oxlintCmd = "oxlint --type-aware --type-check";
|
|
159
158
|
scripts.lint = oxlintCmd;
|
|
160
159
|
scripts["lint:fix"] = `${oxlintCmd} --fix`;
|
|
161
|
-
}
|
|
160
|
+
}
|
|
162
161
|
if (opts.useOxfmt) {
|
|
163
162
|
scripts.format = "oxfmt";
|
|
164
163
|
scripts["format:check"] = "oxfmt --check";
|
|
165
164
|
scripts.fmt = "oxfmt";
|
|
166
165
|
scripts["fmt:check"] = "oxfmt --check";
|
|
167
166
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const devDependencies = { typescript: opts.typescriptVersion };
|
|
167
|
+
}
|
|
168
|
+
function applyLintAndFormatDependencies(devDependencies, opts) {
|
|
171
169
|
if (opts.useOxlint) {
|
|
172
170
|
if (opts.oxlintVersion) devDependencies.oxlint = opts.oxlintVersion;
|
|
173
171
|
if (opts.oxlintTsgolintVersion) devDependencies["oxlint-tsgolint"] = opts.oxlintTsgolintVersion;
|
|
174
172
|
if (opts.kingswordLintConfigVersion) devDependencies["@kingsword/lint-config"] = opts.kingswordLintConfigVersion;
|
|
175
173
|
}
|
|
176
174
|
if (opts.useOxfmt && opts.oxfmtVersion) devDependencies.oxfmt = opts.oxfmtVersion;
|
|
175
|
+
}
|
|
176
|
+
function packageJsonTemplate(opts) {
|
|
177
|
+
const scripts = {};
|
|
178
|
+
if (!opts.useOxlint) scripts.typecheck = "tsc --noEmit";
|
|
179
|
+
applyLintAndFormatScripts(scripts, opts);
|
|
180
|
+
if (opts.useVitest) scripts.test = "vitest";
|
|
181
|
+
if (opts.useTsdown) scripts.build = "tsdown";
|
|
182
|
+
const devDependencies = { typescript: opts.typescriptVersion };
|
|
183
|
+
applyLintAndFormatDependencies(devDependencies, opts);
|
|
177
184
|
if (opts.useVitest && opts.vitestVersion) devDependencies.vitest = opts.vitestVersion;
|
|
178
185
|
if (opts.useTsdown && opts.tsdownVersion) devDependencies.tsdown = opts.tsdownVersion;
|
|
179
186
|
return JSON.stringify({
|
|
@@ -186,6 +193,22 @@ function packageJsonTemplate(opts) {
|
|
|
186
193
|
packageManager: opts.packageManager
|
|
187
194
|
}, null, 2) + "\n";
|
|
188
195
|
}
|
|
196
|
+
function workspaceRootPackageJsonTemplate(opts) {
|
|
197
|
+
const scripts = {};
|
|
198
|
+
applyLintAndFormatScripts(scripts, opts);
|
|
199
|
+
if (opts.useVitest) scripts.test = "pnpm -r --if-present run test";
|
|
200
|
+
if (opts.useTsdown) scripts.build = "pnpm -r --if-present run build";
|
|
201
|
+
const devDependencies = {};
|
|
202
|
+
applyLintAndFormatDependencies(devDependencies, opts);
|
|
203
|
+
const manifest = {
|
|
204
|
+
name: opts.name,
|
|
205
|
+
private: true,
|
|
206
|
+
packageManager: opts.packageManager
|
|
207
|
+
};
|
|
208
|
+
if (Object.keys(scripts).length > 0) manifest.scripts = scripts;
|
|
209
|
+
if (Object.keys(devDependencies).length > 0) manifest.devDependencies = devDependencies;
|
|
210
|
+
return JSON.stringify(manifest, null, 2) + "\n";
|
|
211
|
+
}
|
|
189
212
|
const DEFAULT_WORKFLOWS_REF = "7320d30bcd47cee17cc2d8d28250ba1ab1f742b8";
|
|
190
213
|
const DEFAULT_WORKFLOWS_VERSION = "v1.0.3";
|
|
191
214
|
function resolveWorkflowsPin(opts) {
|
|
@@ -833,6 +856,9 @@ async function runInit({ nameArg }) {
|
|
|
833
856
|
return;
|
|
834
857
|
}
|
|
835
858
|
const pkgDir = pnpmWorkspace ? path.join(rootDir, "packages", projectName) : rootDir;
|
|
859
|
+
const toolingDir = pnpmWorkspace ? rootDir : pkgDir;
|
|
860
|
+
const packageUseOxlint = pnpmWorkspace ? false : useOxlint;
|
|
861
|
+
const packageUseOxfmt = pnpmWorkspace ? false : useOxfmt;
|
|
836
862
|
const pmVersion = await detectPackageManagerVersion(packageManager);
|
|
837
863
|
const packageManagerField = pmVersion ? `${packageManager}@${pmVersion}` : `${packageManager}@latest`;
|
|
838
864
|
await mkdir(path.join(pkgDir, "src"), { recursive: true });
|
|
@@ -847,11 +873,18 @@ async function runInit({ nameArg }) {
|
|
|
847
873
|
" - \"packages/*\"",
|
|
848
874
|
""
|
|
849
875
|
].join("\n"));
|
|
850
|
-
await writeText(path.join(rootDir, "package.json"),
|
|
876
|
+
await writeText(path.join(rootDir, "package.json"), workspaceRootPackageJsonTemplate({
|
|
851
877
|
name: projectName,
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
878
|
+
packageManager: packageManagerField,
|
|
879
|
+
useOxlint,
|
|
880
|
+
oxlintVersion: "latest",
|
|
881
|
+
oxlintTsgolintVersion: "latest",
|
|
882
|
+
kingswordLintConfigVersion: "latest",
|
|
883
|
+
useOxfmt,
|
|
884
|
+
oxfmtVersion: "latest",
|
|
885
|
+
useVitest,
|
|
886
|
+
useTsdown
|
|
887
|
+
}));
|
|
855
888
|
}
|
|
856
889
|
await Promise.all([
|
|
857
890
|
writeText(path.join(pkgDir, "README.md"), readmeTemplate(projectName)),
|
|
@@ -861,11 +894,11 @@ async function runInit({ nameArg }) {
|
|
|
861
894
|
name: projectName,
|
|
862
895
|
packageManager: packageManagerField,
|
|
863
896
|
typescriptVersion: "latest",
|
|
864
|
-
useOxlint,
|
|
897
|
+
useOxlint: packageUseOxlint,
|
|
865
898
|
oxlintVersion: "latest",
|
|
866
899
|
oxlintTsgolintVersion: "latest",
|
|
867
900
|
kingswordLintConfigVersion: "latest",
|
|
868
|
-
useOxfmt,
|
|
901
|
+
useOxfmt: packageUseOxfmt,
|
|
869
902
|
oxfmtVersion: "latest",
|
|
870
903
|
useVitest,
|
|
871
904
|
vitestVersion: "latest",
|
|
@@ -873,13 +906,13 @@ async function runInit({ nameArg }) {
|
|
|
873
906
|
tsdownVersion: "latest"
|
|
874
907
|
}))
|
|
875
908
|
]);
|
|
876
|
-
if (useOxlint) await writeText(path.join(
|
|
877
|
-
if (useOxfmt) await writeText(path.join(
|
|
909
|
+
if (useOxlint) await writeText(path.join(toolingDir, "oxlint.config.ts"), oxlintConfigTemplate({ useVitest }));
|
|
910
|
+
if (useOxfmt) await writeText(path.join(toolingDir, ".oxfmtrc.json"), oxfmtConfigTemplate());
|
|
878
911
|
if (useVitest) await writeText(path.join(pkgDir, "src/index.test.ts"), srcVitestTemplate());
|
|
879
912
|
if (useTsdown) await writeText(path.join(pkgDir, "tsdown.config.ts"), tsdownConfigTemplate());
|
|
880
913
|
if (packageManager === "deno") await writeText(path.join(rootDir, "deno.json"), JSON.stringify({ nodeModulesDir: "auto" }, null, 2) + "\n");
|
|
881
914
|
if (githubActions !== "none") {
|
|
882
|
-
const workingDirectory =
|
|
915
|
+
const workingDirectory = ".";
|
|
883
916
|
const lintCommand = useOxlint && packageManager !== "deno" ? pmRun(packageManager, "lint") : void 0;
|
|
884
917
|
const formatCheckCommand = useOxfmt && packageManager !== "deno" ? pmRun(packageManager, "format:check") : void 0;
|
|
885
918
|
const testCommand = useVitest && packageManager !== "deno" ? pmRun(packageManager, "test") : void 0;
|
|
@@ -1454,4 +1487,4 @@ function abort(opts = {}) {
|
|
|
1454
1487
|
}
|
|
1455
1488
|
|
|
1456
1489
|
//#endregion
|
|
1457
|
-
export { runCi as a, oxlintConfigTemplate as c, validateProjectName as i, packageJsonTemplate as l, runOxlint as n, githubCliCiWorkflowTemplate as o, runInit as r, githubDependabotTemplate as s, runOxfmt as t };
|
|
1490
|
+
export { runCi as a, oxlintConfigTemplate as c, validateProjectName as i, packageJsonTemplate as l, runOxlint as n, githubCliCiWorkflowTemplate as o, runInit as r, githubDependabotTemplate as s, runOxfmt as t, workspaceRootPackageJsonTemplate as u };
|