@frigear-nu/cli 0.0.0 → 0.1.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 +2 -2
- package/dist/chunks/add.mjs +1 -1
- package/dist/chunks/app-create.mjs +1 -1
- package/dist/chunks/init.mjs +58 -25
- package/dist/chunks/module-create.mjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +28 -6
- package/dist/index.d.ts +28 -6
- package/dist/index.mjs +3 -3
- package/dist/shared/{cli.CfDN9-ET.mjs → cli.CeeYOUjI.mjs} +1 -1
- package/dist/shared/{cli.BTkbFZ3J.mjs → cli.Cfkcp0w9.mjs} +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ pnpx @frigear-nu/cli --help
|
|
|
9
9
|
|
|
10
10
|
| Command | What it does |
|
|
11
11
|
| --- | --- |
|
|
12
|
-
| `init [dir] --
|
|
12
|
+
| `init [dir] --platform <web\|mobile\|web,mobile>` | New project from a starter (or `-t <giget source>`), then `pnpm install` and `pnpm prepare:env`. |
|
|
13
13
|
| `app:create <name> --template <web\|web-standalone\|mobile>` | Adds a starter's app to `apps/<name>`. |
|
|
14
14
|
| `module:create <name> [--scope @acme]` | Scaffolds a Nuxt module in `packages/<name>`. |
|
|
15
15
|
| `add <module...> [--app <app>]` | `pnpm add` in the app and adds the modules to its `nuxt.config`. |
|
|
@@ -17,7 +17,7 @@ pnpx @frigear-nu/cli --help
|
|
|
17
17
|
Starters are downloaded from `Frigear-nu/frigear-nu` with [giget](https://github.com/unjs/giget) (`--ref` picks a branch
|
|
18
18
|
or tag). While that repository is not public, set `GIGET_AUTH` to a GitHub token that can read it.
|
|
19
19
|
|
|
20
|
-
`pnpm create frigear-app` ([create-frigear-app](../create-frigear-app))
|
|
20
|
+
`pnpm create frigear-app` ([create-frigear-app](../create-frigear-app)) runs `init` of the latest CLI.
|
|
21
21
|
|
|
22
22
|
Full reference: [docs.frigear.dev/contribute/tooling/cli](https://docs.frigear.dev/contribute/tooling/cli).
|
|
23
23
|
|
package/dist/chunks/add.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { readFile, writeFile } from 'node:fs/promises';
|
|
|
5
5
|
import { resolve, join, relative } from 'node:path';
|
|
6
6
|
import { parseModule, generateCode } from 'magicast';
|
|
7
7
|
import { getDefaultExportOptions, addNuxtModule } from 'magicast/helpers';
|
|
8
|
-
import {
|
|
8
|
+
import { a as readPackage, d as defineCommandArgs, f as findWorkspaceRoot, l as listDirs } from '../shared/cli.Cfkcp0w9.mjs';
|
|
9
9
|
import { a as addDeps } from '../shared/cli.CCJgOooL.mjs';
|
|
10
10
|
import 'scule';
|
|
11
11
|
import 'pkg-types';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineCommand } from 'citty';
|
|
2
2
|
import consola from 'consola';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import { f as findWorkspaceRoot, t as toPackageName, h as hasPackage, r as renamePackage, d as defineCommandArgs,
|
|
4
|
+
import { f as findWorkspaceRoot, t as toPackageName, h as hasPackage, r as renamePackage, d as defineCommandArgs, b as templateArgs, l as listDirs, p as packageScope, a as readPackage } from '../shared/cli.Cfkcp0w9.mjs';
|
|
5
5
|
import { i as installDeps } from '../shared/cli.CCJgOooL.mjs';
|
|
6
6
|
import { d as downloadTemplateToDir, r as repoSource } from '../shared/cli.C_62nhcg.mjs';
|
|
7
7
|
import 'scule';
|
package/dist/chunks/init.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineCommand } from 'citty';
|
|
2
2
|
import consola from 'consola';
|
|
3
3
|
import { resolve, basename, relative } from 'node:path';
|
|
4
|
-
import { i as isEmptyDir, r as renamePackage, t as toPackageName, d as defineCommandArgs,
|
|
4
|
+
import { i as isEmptyDir, h as hasPackage, r as renamePackage, t as toPackageName, a as readPackage, d as defineCommandArgs, b as templateArgs } from '../shared/cli.Cfkcp0w9.mjs';
|
|
5
5
|
import { i as installDeps, r as runPackageScript } from '../shared/cli.CCJgOooL.mjs';
|
|
6
6
|
import { d as downloadTemplateToDir, r as repoSource } from '../shared/cli.C_62nhcg.mjs';
|
|
7
7
|
import 'scule';
|
|
@@ -11,16 +11,28 @@ import 'pkg-types';
|
|
|
11
11
|
import 'nypm';
|
|
12
12
|
import 'giget';
|
|
13
13
|
|
|
14
|
+
const PLATFORMS = ["web", "mobile"];
|
|
14
15
|
const STARTERS = {
|
|
15
|
-
"workspace": "apps/web: users, auth, account and admin",
|
|
16
|
-
"mobile": "apps/mobile: a Capacitor app against any OAuth issuer",
|
|
17
|
-
"mobile-standalone": "
|
|
16
|
+
"workspace": { platforms: ["web"], hint: "apps/web: users, auth, account and admin" },
|
|
17
|
+
"mobile": { platforms: ["mobile"], hint: "apps/mobile: a Capacitor app against any OAuth issuer" },
|
|
18
|
+
"mobile-standalone": { platforms: ["web", "mobile"], hint: "apps/web + apps/mobile, with apps/web as the OAuth server" }
|
|
18
19
|
};
|
|
19
|
-
const isStarter = (value) =>
|
|
20
|
+
const isStarter = (value) => value in STARTERS;
|
|
21
|
+
const resolveStarter = (value) => {
|
|
22
|
+
const input = value.trim().toLowerCase();
|
|
23
|
+
if (isStarter(input))
|
|
24
|
+
return input;
|
|
25
|
+
const platforms = new Set(input.split(",").map((platform) => platform.trim()).filter(Boolean));
|
|
26
|
+
return Object.keys(STARTERS).find((starter) => {
|
|
27
|
+
const own = STARTERS[starter].platforms;
|
|
28
|
+
return own.length === platforms.size && own.every((platform) => platforms.has(platform));
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const choices = `${PLATFORMS.join(", ")}, ${PLATFORMS.join(",")} or a starter: ${Object.keys(STARTERS).join(", ")}`;
|
|
20
32
|
const init = defineCommand({
|
|
21
33
|
meta: {
|
|
22
34
|
name: "init",
|
|
23
|
-
description: "Create a new project from a Frigear starter"
|
|
35
|
+
description: "Create a new project from a Frigear starter or any giget template"
|
|
24
36
|
},
|
|
25
37
|
args: defineCommandArgs({
|
|
26
38
|
dir: {
|
|
@@ -29,9 +41,15 @@ const init = defineCommand({
|
|
|
29
41
|
required: false,
|
|
30
42
|
default: "frigear-app"
|
|
31
43
|
},
|
|
32
|
-
|
|
44
|
+
platform: {
|
|
45
|
+
type: "string",
|
|
46
|
+
alias: ["starter"],
|
|
47
|
+
description: `What to build (default web): ${choices}`
|
|
48
|
+
},
|
|
49
|
+
template: {
|
|
33
50
|
type: "string",
|
|
34
|
-
|
|
51
|
+
alias: ["t"],
|
|
52
|
+
description: "A giget source to copy instead of a starter, e.g. gh:org/repo/path#ref"
|
|
35
53
|
},
|
|
36
54
|
force: {
|
|
37
55
|
type: "boolean",
|
|
@@ -43,48 +61,63 @@ const init = defineCommand({
|
|
|
43
61
|
async run({ args }) {
|
|
44
62
|
const logger = consola.withTag("init");
|
|
45
63
|
const dir = resolve(args.cwd, args.dir);
|
|
46
|
-
let starter
|
|
47
|
-
if (
|
|
48
|
-
|
|
64
|
+
let starter;
|
|
65
|
+
if (args.template !== void 0) {
|
|
66
|
+
if (args.platform !== void 0) {
|
|
67
|
+
logger.error("Pass either --template or --platform, not both.");
|
|
68
|
+
return process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
} else if (args.platform !== void 0) {
|
|
71
|
+
starter = resolveStarter(args.platform);
|
|
72
|
+
if (!starter) {
|
|
73
|
+
logger.error(`Unknown platform or starter "${args.platform}". Use ${choices}.`);
|
|
74
|
+
return process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
starter = process.stdin.isTTY ? await consola.prompt("What do you want to build?", {
|
|
49
78
|
type: "select",
|
|
50
|
-
options: Object.
|
|
79
|
+
options: Object.keys(STARTERS).map((value) => ({
|
|
80
|
+
value,
|
|
81
|
+
label: `${STARTERS[value].platforms.join(" + ")} (${value})`,
|
|
82
|
+
hint: STARTERS[value].hint
|
|
83
|
+
})),
|
|
51
84
|
initial: "workspace",
|
|
52
85
|
cancel: "reject"
|
|
53
86
|
}) : "workspace";
|
|
54
87
|
}
|
|
55
|
-
if (!isStarter(starter)) {
|
|
56
|
-
logger.error(`Unknown starter "${starter}". Use one of: ${Object.keys(STARTERS).join(", ")}`);
|
|
57
|
-
return process.exit(1);
|
|
58
|
-
}
|
|
59
88
|
if (!args.force && !await isEmptyDir(dir)) {
|
|
60
89
|
logger.error(`${dir} is not empty. Pick another directory or pass --force.`);
|
|
61
90
|
return process.exit(1);
|
|
62
91
|
}
|
|
92
|
+
const label = starter ? `the ${starter} starter` : args.template;
|
|
63
93
|
await downloadTemplateToDir({
|
|
64
|
-
template: repoSource(`.starters/${starter}`, args.ref),
|
|
94
|
+
template: starter ? repoSource(`.starters/${starter}`, args.ref) : args.template,
|
|
65
95
|
path: dir,
|
|
66
96
|
force: args.force
|
|
67
97
|
}).catch((error) => {
|
|
68
|
-
logger.error(`Failed to download
|
|
98
|
+
logger.error(`Failed to download ${label}`);
|
|
69
99
|
logger.error(error instanceof Error ? error.message : error);
|
|
70
100
|
return process.exit(1);
|
|
71
101
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
102
|
+
if (hasPackage(dir))
|
|
103
|
+
await renamePackage(dir, toPackageName(basename(dir)));
|
|
104
|
+
logger.success(`Created ${label} in ${dir}`);
|
|
105
|
+
const hasPrepareEnv = !!(await readPackage(dir))?.scripts?.["prepare:env"];
|
|
106
|
+
if (args.install && hasPackage(dir)) {
|
|
75
107
|
logger.start("Installing dependencies");
|
|
76
108
|
await installDeps(dir);
|
|
77
|
-
|
|
109
|
+
if (hasPrepareEnv)
|
|
110
|
+
await runPackageScript("prepare:env", dir);
|
|
78
111
|
}
|
|
79
112
|
const cd = relative(args.cwd, dir) || ".";
|
|
80
113
|
logger.box([
|
|
81
114
|
"Next steps:",
|
|
82
115
|
cd === "." ? void 0 : ` cd ${cd}`,
|
|
83
|
-
args.install ? void 0 :
|
|
84
|
-
|
|
116
|
+
args.install ? void 0 : ` pnpm install${hasPrepareEnv ? " && pnpm prepare:env" : ""}`,
|
|
117
|
+
...!starter ? [] : starter === "mobile" ? [" set NUXT_PUBLIC_AUTHENTICATION_CLIENT_ISSUER (and _API_BASE) in apps/mobile/.env"] : [" put your email in NUXT_ACL_ADMINS in apps/web/.env"],
|
|
85
118
|
" pnpm dev"
|
|
86
119
|
].filter(Boolean).join("\n"));
|
|
87
120
|
}
|
|
88
121
|
});
|
|
89
122
|
|
|
90
|
-
export { STARTERS, init as default };
|
|
123
|
+
export { PLATFORMS, STARTERS, init as default, resolveStarter };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineCommand } from 'citty';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
|
-
import { t as toPackageName, f as findWorkspaceRoot, h as hasPackage, r as renamePackage, d as defineCommandArgs, p as packageScope,
|
|
3
|
+
import { t as toPackageName, f as findWorkspaceRoot, h as hasPackage, r as renamePackage, d as defineCommandArgs, p as packageScope, a as readPackage } from '../shared/cli.Cfkcp0w9.mjs';
|
|
4
4
|
import { d as downloadTemplateToDir } from '../shared/cli.C_62nhcg.mjs';
|
|
5
5
|
import consola from 'consola';
|
|
6
6
|
import 'scule';
|
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -3,12 +3,28 @@ import * as citty from 'citty';
|
|
|
3
3
|
declare const mainCmd: citty.CommandDef<citty.ArgsDef>;
|
|
4
4
|
declare function main(): Promise<void>;
|
|
5
5
|
|
|
6
|
+
declare const PLATFORMS: readonly ["web", "mobile"];
|
|
7
|
+
type Platform = typeof PLATFORMS[number];
|
|
8
|
+
/** Each starter (a folder under `.starters/`) and the platforms it builds for. */
|
|
6
9
|
declare const STARTERS: {
|
|
7
|
-
readonly workspace:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
readonly workspace: {
|
|
11
|
+
readonly platforms: readonly ["web"];
|
|
12
|
+
readonly hint: "apps/web: users, auth, account and admin";
|
|
13
|
+
};
|
|
14
|
+
readonly mobile: {
|
|
15
|
+
readonly platforms: readonly ["mobile"];
|
|
16
|
+
readonly hint: "apps/mobile: a Capacitor app against any OAuth issuer";
|
|
17
|
+
};
|
|
18
|
+
readonly 'mobile-standalone': {
|
|
19
|
+
readonly platforms: readonly ["web", "mobile"];
|
|
20
|
+
readonly hint: "apps/web + apps/mobile, with apps/web as the OAuth server";
|
|
21
|
+
};
|
|
10
22
|
};
|
|
11
23
|
type Starter = keyof typeof STARTERS;
|
|
24
|
+
/**
|
|
25
|
+
* A starter from its name (`mobile-standalone`) or from its platforms (`web`, `mobile`, `web,mobile`, in any order).
|
|
26
|
+
*/
|
|
27
|
+
declare const resolveStarter: (value: string) => Starter | undefined;
|
|
12
28
|
declare const _default: citty.CommandDef<{
|
|
13
29
|
cwd: {
|
|
14
30
|
type: "string";
|
|
@@ -32,8 +48,14 @@ declare const _default: citty.CommandDef<{
|
|
|
32
48
|
required: false;
|
|
33
49
|
default: string;
|
|
34
50
|
};
|
|
35
|
-
|
|
51
|
+
platform: {
|
|
52
|
+
type: "string";
|
|
53
|
+
alias: string[];
|
|
54
|
+
description: string;
|
|
55
|
+
};
|
|
56
|
+
template: {
|
|
36
57
|
type: "string";
|
|
58
|
+
alias: string[];
|
|
37
59
|
description: string;
|
|
38
60
|
};
|
|
39
61
|
force: {
|
|
@@ -43,5 +65,5 @@ declare const _default: citty.CommandDef<{
|
|
|
43
65
|
};
|
|
44
66
|
}>;
|
|
45
67
|
|
|
46
|
-
export { STARTERS, main as default, _default as initCmd, mainCmd };
|
|
47
|
-
export type { Starter };
|
|
68
|
+
export { PLATFORMS, STARTERS, main as default, _default as initCmd, mainCmd, resolveStarter };
|
|
69
|
+
export type { Platform, Starter };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,28 @@ import * as citty from 'citty';
|
|
|
3
3
|
declare const mainCmd: citty.CommandDef<citty.ArgsDef>;
|
|
4
4
|
declare function main(): Promise<void>;
|
|
5
5
|
|
|
6
|
+
declare const PLATFORMS: readonly ["web", "mobile"];
|
|
7
|
+
type Platform = typeof PLATFORMS[number];
|
|
8
|
+
/** Each starter (a folder under `.starters/`) and the platforms it builds for. */
|
|
6
9
|
declare const STARTERS: {
|
|
7
|
-
readonly workspace:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
readonly workspace: {
|
|
11
|
+
readonly platforms: readonly ["web"];
|
|
12
|
+
readonly hint: "apps/web: users, auth, account and admin";
|
|
13
|
+
};
|
|
14
|
+
readonly mobile: {
|
|
15
|
+
readonly platforms: readonly ["mobile"];
|
|
16
|
+
readonly hint: "apps/mobile: a Capacitor app against any OAuth issuer";
|
|
17
|
+
};
|
|
18
|
+
readonly 'mobile-standalone': {
|
|
19
|
+
readonly platforms: readonly ["web", "mobile"];
|
|
20
|
+
readonly hint: "apps/web + apps/mobile, with apps/web as the OAuth server";
|
|
21
|
+
};
|
|
10
22
|
};
|
|
11
23
|
type Starter = keyof typeof STARTERS;
|
|
24
|
+
/**
|
|
25
|
+
* A starter from its name (`mobile-standalone`) or from its platforms (`web`, `mobile`, `web,mobile`, in any order).
|
|
26
|
+
*/
|
|
27
|
+
declare const resolveStarter: (value: string) => Starter | undefined;
|
|
12
28
|
declare const _default: citty.CommandDef<{
|
|
13
29
|
cwd: {
|
|
14
30
|
type: "string";
|
|
@@ -32,8 +48,14 @@ declare const _default: citty.CommandDef<{
|
|
|
32
48
|
required: false;
|
|
33
49
|
default: string;
|
|
34
50
|
};
|
|
35
|
-
|
|
51
|
+
platform: {
|
|
52
|
+
type: "string";
|
|
53
|
+
alias: string[];
|
|
54
|
+
description: string;
|
|
55
|
+
};
|
|
56
|
+
template: {
|
|
36
57
|
type: "string";
|
|
58
|
+
alias: string[];
|
|
37
59
|
description: string;
|
|
38
60
|
};
|
|
39
61
|
force: {
|
|
@@ -43,5 +65,5 @@ declare const _default: citty.CommandDef<{
|
|
|
43
65
|
};
|
|
44
66
|
}>;
|
|
45
67
|
|
|
46
|
-
export { STARTERS, main as default, _default as initCmd, mainCmd };
|
|
47
|
-
export type { Starter };
|
|
68
|
+
export { PLATFORMS, STARTERS, main as default, _default as initCmd, mainCmd, resolveStarter };
|
|
69
|
+
export type { Platform, Starter };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { m as default, a as mainCmd } from './shared/cli.
|
|
2
|
-
export { STARTERS, default as initCmd } from './chunks/init.mjs';
|
|
1
|
+
export { m as default, a as mainCmd } from './shared/cli.CeeYOUjI.mjs';
|
|
2
|
+
export { PLATFORMS, STARTERS, default as initCmd, resolveStarter } from './chunks/init.mjs';
|
|
3
3
|
import 'citty';
|
|
4
4
|
import 'consola';
|
|
5
5
|
import 'node:path';
|
|
6
|
-
import './shared/cli.
|
|
6
|
+
import './shared/cli.Cfkcp0w9.mjs';
|
|
7
7
|
import 'scule';
|
|
8
8
|
import 'node:fs';
|
|
9
9
|
import 'node:fs/promises';
|
|
@@ -55,4 +55,4 @@ const listDirs = async (dir) => {
|
|
|
55
55
|
const isEmptyDir = async (dir) => !existsSync(dir) || (await readdir(dir)).length === 0;
|
|
56
56
|
const toPackageName = (name) => kebabCase(name.replace(/[^\w-]+/g, "-")).replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
57
57
|
|
|
58
|
-
export {
|
|
58
|
+
export { readPackage as a, templateArgs as b, defineCommandArgs as d, findWorkspaceRoot as f, hasPackage as h, isEmptyDir as i, listDirs as l, packageScope as p, renamePackage as r, toPackageName as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frigear-nu/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Frigear CLI: scaffold projects, apps and modules, and add Frigear modules to an app.",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"scule": "^1.3.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@frigear-nu/eslint-config": "^0.2.
|
|
47
|
+
"@frigear-nu/eslint-config": "^0.2.3",
|
|
48
48
|
"@types/node": "^26.6.5",
|
|
49
49
|
"eslint": "^10.12.0",
|
|
50
50
|
"jiti": "^2.7.0",
|