@frigear-nu/cli 0.2.3 → 0.2.5
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 +7 -2
- package/dist/chunks/add.mjs +66 -69
- package/dist/chunks/add2.mjs +93 -0
- package/dist/chunks/app-create.mjs +28 -52
- package/dist/chunks/init.mjs +4 -3
- package/dist/chunks/init2.mjs +53 -0
- package/dist/chunks/list.mjs +48 -0
- package/dist/chunks/module-create.mjs +2 -2
- package/dist/chunks/module-folder.mjs +5 -4
- package/dist/chunks/module-move.mjs +5 -5
- package/dist/chunks/package-rename.mjs +1 -2
- package/dist/chunks/platform.mjs +15 -0
- package/dist/chunks/upgrade.mjs +51 -4
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +226 -2
- package/dist/index.d.ts +226 -2
- package/dist/index.mjs +13 -9
- package/dist/shared/cli.B8wGY3pU.mjs +127 -0
- package/dist/shared/{cli.C_0i5HKZ.mjs → cli.B9jOPxYC.mjs} +1 -1
- package/dist/shared/cli.BVDx1SIR.mjs +84 -0
- package/dist/shared/cli.C-q4Gf2K.mjs +18 -0
- package/dist/shared/cli.CJ66durw.mjs +22 -0
- package/dist/shared/{cli.DUmSgMcB.mjs → cli.CU1tZqxU.mjs} +90 -2
- package/dist/shared/{cli.CybmnaqF.mjs → cli.DAggATZw.mjs} +1 -1
- package/dist/shared/cli.DEhqG8Aw.mjs +119 -0
- package/dist/shared/{cli.BRfEZGZ1.mjs → cli.DX_up8fP.mjs} +3 -2
- package/package.json +5 -4
- package/dist/shared/cli.Cfkcp0w9.mjs +0 -58
- package/dist/shared/cli.CkMCvUCp.mjs +0 -7
package/README.md
CHANGED
|
@@ -10,13 +10,18 @@ pnpx @frigear-nu/cli --help
|
|
|
10
10
|
| Command | What it does |
|
|
11
11
|
| --- | --- |
|
|
12
12
|
| `init [dir] --platform <web\|mobile\|desktop\|web,mobile\|web,mobile,desktop>` | New project from a starter (or `-t <giget source>`), then `pnpm install` and `pnpm prepare:env`. |
|
|
13
|
-
| `
|
|
13
|
+
| `platform add <platform> [name] [-t <template>] [--apps-dir auto\|<dir>]` | Adds an app of a platform (web, mobile, desktop or a project's own) and its root scripts; from the root or the apps folder. |
|
|
14
|
+
| `platform init <ios\|android\|apple-watch\|tauri\|...> [--app <name>]` | Sets up a native target in an app through its own tooling. |
|
|
15
|
+
| `platform list` | Platforms, templates, targets and the workspace's apps. |
|
|
16
|
+
| `app:create <name> --template <web\|web-standalone\|mobile\|desktop>` | `platform add <template> <name>`. |
|
|
14
17
|
| `module:create <name> [--scope @acme]` | Scaffolds a Nuxt module in `packages/<name>`. |
|
|
15
18
|
| `add <module...> [--app <app>]` | `pnpm add` in the app and adds the modules to its `nuxt.config`. |
|
|
16
19
|
| `package:rename <package> <new-name> [--dir]` | Renames a workspace package in manifests, `pnpm-workspace.yaml`, imports and config. |
|
|
17
20
|
| `module:folder <module> [--runtime]` | Turns `modules/foo.ts` into `modules/foo/index.ts`. |
|
|
18
21
|
| `module:move <module> <destination> [--name <name>]` | Moves a local module or package folder and fixes relative paths. |
|
|
19
22
|
|
|
23
|
+
`addPlatform`, `initPlatform` and `definePlatform` are exported for use from code.
|
|
24
|
+
|
|
20
25
|
The three refactoring commands take `--dry-run` to print the changes without writing them.
|
|
21
26
|
|
|
22
27
|
Starters are downloaded from `Frigear-nu/frigear-nu` with [giget](https://github.com/unjs/giget) (`--ref` picks a branch
|
|
@@ -24,7 +29,7 @@ or tag). While that repository is not public, set `GIGET_AUTH` to a GitHub token
|
|
|
24
29
|
|
|
25
30
|
`pnpm create frigear-app` ([create-frigear-app](../create-frigear-app)) runs `init` of the latest CLI.
|
|
26
31
|
|
|
27
|
-
Full reference: [docs.frigear.dev/
|
|
32
|
+
Full reference: [docs.frigear.dev/cli/overview](https://docs.frigear.dev/cli/overview).
|
|
28
33
|
|
|
29
34
|
## In this repository
|
|
30
35
|
|
package/dist/chunks/add.mjs
CHANGED
|
@@ -1,92 +1,89 @@
|
|
|
1
1
|
import { defineCommand } from 'citty';
|
|
2
2
|
import consola from 'consola';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { getDefaultExportOptions, addNuxtModule } from 'magicast/helpers';
|
|
8
|
-
import { a as readPackage, d as defineCommandArgs, f as findWorkspaceRoot, l as listDirs } from '../shared/cli.Cfkcp0w9.mjs';
|
|
9
|
-
import { a as addDeps } from '../shared/cli.CkMCvUCp.mjs';
|
|
10
|
-
import 'scule';
|
|
3
|
+
import { relative } from 'node:path';
|
|
4
|
+
import { a as addPlatform } from '../shared/cli.DEhqG8Aw.mjs';
|
|
5
|
+
import { P as PlatformError, t as toPackageName, d as defineCommandArgs, c as templateArgs } from '../shared/cli.CU1tZqxU.mjs';
|
|
6
|
+
import { e as exitWith, a as appsDirArg } from '../shared/cli.CJ66durw.mjs';
|
|
11
7
|
import 'pkg-types';
|
|
8
|
+
import '../shared/cli.C-q4Gf2K.mjs';
|
|
12
9
|
import 'nypm';
|
|
10
|
+
import 'tinyexec';
|
|
11
|
+
import '../shared/cli.BLUxtpPi.mjs';
|
|
12
|
+
import 'node:fs';
|
|
13
|
+
import 'node:fs/promises';
|
|
14
|
+
import '../shared/cli.B9jOPxYC.mjs';
|
|
15
|
+
import 'giget';
|
|
16
|
+
import 'node:os';
|
|
17
|
+
import '../shared/cli.B8wGY3pU.mjs';
|
|
18
|
+
import 'scule';
|
|
13
19
|
|
|
14
|
-
const NUXT_CONFIGS = ["nuxt.config.ts", "nuxt.config.mts", "nuxt.config.js", "nuxt.config.mjs"];
|
|
15
|
-
const resolveModuleName = (name) => name.includes("/") ? name : `@frigear-nu/${name}`;
|
|
16
|
-
const findNuxtConfig = (dir) => NUXT_CONFIGS.map((file) => join(dir, file)).find(existsSync);
|
|
17
|
-
const resolveTargetApp = async (cwd, app) => {
|
|
18
|
-
if (app) {
|
|
19
|
-
const root2 = await findWorkspaceRoot(cwd) ?? cwd;
|
|
20
|
-
const candidates = [resolve(cwd, app), join(root2, "apps", app)];
|
|
21
|
-
const dir = candidates.find(findNuxtConfig);
|
|
22
|
-
if (!dir) throw new Error(`No nuxt.config found in ${candidates.join(" or ")}`);
|
|
23
|
-
return dir;
|
|
24
|
-
}
|
|
25
|
-
if (findNuxtConfig(cwd)) return cwd;
|
|
26
|
-
const root = await findWorkspaceRoot(cwd);
|
|
27
|
-
const apps = root ? (await listDirs(join(root, "apps"))).filter(findNuxtConfig) : [];
|
|
28
|
-
if (apps.length === 1) return apps[0];
|
|
29
|
-
if (apps.length === 0) throw new Error(`No Nuxt app found in ${cwd}. Pass --app <dir>.`);
|
|
30
|
-
throw new Error(`Several Nuxt apps found (${apps.map((dir) => relative(root, dir)).join(", ")}). Pass --app <name>.`);
|
|
31
|
-
};
|
|
32
|
-
const addModulesToConfig = async (configPath, modules) => {
|
|
33
|
-
const mod = parseModule(await readFile(configPath, "utf-8"));
|
|
34
|
-
const config = getDefaultExportOptions(mod);
|
|
35
|
-
const added = modules.filter((name) => !config.modules?.includes(name));
|
|
36
|
-
for (const name of added) addNuxtModule(mod, name);
|
|
37
|
-
if (added.length) await writeFile(configPath, `${generateCode(mod).code.trimEnd()}
|
|
38
|
-
`, "utf-8");
|
|
39
|
-
return added;
|
|
40
|
-
};
|
|
41
20
|
const add = defineCommand({
|
|
42
21
|
meta: {
|
|
43
22
|
name: "add",
|
|
44
|
-
description: "
|
|
23
|
+
description: "Add an app of a platform (web, mobile, desktop, or your own) to the workspace"
|
|
45
24
|
},
|
|
46
25
|
args: defineCommandArgs({
|
|
47
|
-
|
|
26
|
+
platform: {
|
|
48
27
|
type: "positional",
|
|
49
|
-
description: "
|
|
28
|
+
description: "Platform: web, web-standalone, mobile, desktop, or one from frigear.platforms in the root package.json",
|
|
50
29
|
required: true
|
|
51
30
|
},
|
|
52
|
-
|
|
31
|
+
name: {
|
|
32
|
+
type: "positional",
|
|
33
|
+
description: "Folder name of the app (default: the platform name)",
|
|
34
|
+
required: false
|
|
35
|
+
},
|
|
36
|
+
template: {
|
|
53
37
|
type: "string",
|
|
54
|
-
|
|
38
|
+
alias: ["t"],
|
|
39
|
+
description: "Template name (web, web-standalone, mobile, desktop, or frigear.templates) or a giget source"
|
|
55
40
|
},
|
|
56
|
-
|
|
41
|
+
scripts: {
|
|
57
42
|
type: "boolean",
|
|
58
|
-
description: "
|
|
43
|
+
description: "Add the platform's scripts to the root package.json (--no-scripts to skip)",
|
|
59
44
|
default: true
|
|
60
|
-
}
|
|
45
|
+
},
|
|
46
|
+
...appsDirArg,
|
|
47
|
+
...templateArgs
|
|
61
48
|
}),
|
|
62
49
|
async run({ args }) {
|
|
63
|
-
const logger = consola.withTag("add");
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
50
|
+
const logger = consola.withTag("platform add");
|
|
51
|
+
const options = {
|
|
52
|
+
cwd: args.cwd,
|
|
53
|
+
platform: args.platform,
|
|
54
|
+
template: args.template,
|
|
55
|
+
appsDir: args["apps-dir"],
|
|
56
|
+
ref: args.ref,
|
|
57
|
+
scripts: args.scripts,
|
|
58
|
+
install: args.install,
|
|
59
|
+
logger
|
|
60
|
+
};
|
|
61
|
+
let name = args.name;
|
|
62
|
+
let result;
|
|
63
|
+
while (!result) {
|
|
64
|
+
try {
|
|
65
|
+
result = await addPlatform({ ...options, name });
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (error instanceof PlatformError && error.code === "APP_EXISTS" && process.stdin.isTTY) {
|
|
68
|
+
logger.warn(error.message);
|
|
69
|
+
const answer = await consola.prompt("Name of the new app", { type: "text", cancel: "reject" });
|
|
70
|
+
name = toPackageName(answer);
|
|
71
|
+
if (!name) return exitWith(logger, error);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
return exitWith(logger, error);
|
|
75
|
+
}
|
|
87
76
|
}
|
|
88
|
-
|
|
77
|
+
const cd = relative(args.cwd, result.root);
|
|
78
|
+
logger.box([
|
|
79
|
+
"Next steps:",
|
|
80
|
+
cd ? ` cd ${cd}` : void 0,
|
|
81
|
+
args.install ? void 0 : " pnpm install",
|
|
82
|
+
...result.nextSteps,
|
|
83
|
+
` pnpm dev:${result.appName}`,
|
|
84
|
+
result.scripts.added.some((key) => key.startsWith("dev:")) ? ` (add --filter ./${relative(result.root, result.appDir)} to the root "dev" script to start it with the others)` : void 0
|
|
85
|
+
].filter(Boolean).join("\n"));
|
|
89
86
|
}
|
|
90
87
|
});
|
|
91
88
|
|
|
92
|
-
export {
|
|
89
|
+
export { add as default };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { defineCommand } from 'citty';
|
|
2
|
+
import consola from 'consola';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
5
|
+
import { resolve, join, relative } from 'node:path';
|
|
6
|
+
import { parseModule, generateCode } from 'magicast';
|
|
7
|
+
import { getDefaultExportOptions, addNuxtModule } from 'magicast/helpers';
|
|
8
|
+
import { b as readPackage, d as defineCommandArgs, f as findWorkspaceRoot, l as listDirs } from '../shared/cli.CU1tZqxU.mjs';
|
|
9
|
+
import { a as addDeps } from '../shared/cli.C-q4Gf2K.mjs';
|
|
10
|
+
import 'scule';
|
|
11
|
+
import 'pkg-types';
|
|
12
|
+
import 'nypm';
|
|
13
|
+
import 'tinyexec';
|
|
14
|
+
|
|
15
|
+
const NUXT_CONFIGS = ["nuxt.config.ts", "nuxt.config.mts", "nuxt.config.js", "nuxt.config.mjs"];
|
|
16
|
+
const resolveModuleName = (name) => name.includes("/") ? name : `@frigear-nu/${name}`;
|
|
17
|
+
const findNuxtConfig = (dir) => NUXT_CONFIGS.map((file) => join(dir, file)).find(existsSync);
|
|
18
|
+
const resolveTargetApp = async (cwd, app) => {
|
|
19
|
+
if (app) {
|
|
20
|
+
const root2 = await findWorkspaceRoot(cwd) ?? cwd;
|
|
21
|
+
const candidates = [resolve(cwd, app), join(root2, "apps", app)];
|
|
22
|
+
const dir = candidates.find(findNuxtConfig);
|
|
23
|
+
if (!dir) throw new Error(`No nuxt.config found in ${candidates.join(" or ")}`);
|
|
24
|
+
return dir;
|
|
25
|
+
}
|
|
26
|
+
if (findNuxtConfig(cwd)) return cwd;
|
|
27
|
+
const root = await findWorkspaceRoot(cwd);
|
|
28
|
+
const apps = root ? (await listDirs(join(root, "apps"))).filter(findNuxtConfig) : [];
|
|
29
|
+
if (apps.length === 1) return apps[0];
|
|
30
|
+
if (apps.length === 0) throw new Error(`No Nuxt app found in ${cwd}. Pass --app <dir>.`);
|
|
31
|
+
throw new Error(`Several Nuxt apps found (${apps.map((dir) => relative(root, dir)).join(", ")}). Pass --app <name>.`);
|
|
32
|
+
};
|
|
33
|
+
const addModulesToConfig = async (configPath, modules) => {
|
|
34
|
+
const mod = parseModule(await readFile(configPath, "utf-8"));
|
|
35
|
+
const config = getDefaultExportOptions(mod);
|
|
36
|
+
const added = modules.filter((name) => !config.modules?.includes(name));
|
|
37
|
+
for (const name of added) addNuxtModule(mod, name);
|
|
38
|
+
if (added.length) await writeFile(configPath, `${generateCode(mod).code.trimEnd()}
|
|
39
|
+
`, "utf-8");
|
|
40
|
+
return added;
|
|
41
|
+
};
|
|
42
|
+
const add = defineCommand({
|
|
43
|
+
meta: {
|
|
44
|
+
name: "add",
|
|
45
|
+
description: "Install Frigear modules in a Nuxt app and add them to its nuxt.config"
|
|
46
|
+
},
|
|
47
|
+
args: defineCommandArgs({
|
|
48
|
+
modules: {
|
|
49
|
+
type: "positional",
|
|
50
|
+
description: "Modules to add e.g. forms or @frigear-nu/forms",
|
|
51
|
+
required: true
|
|
52
|
+
},
|
|
53
|
+
app: {
|
|
54
|
+
type: "string",
|
|
55
|
+
description: "App to add the modules to: a path, or a folder under apps/"
|
|
56
|
+
},
|
|
57
|
+
install: {
|
|
58
|
+
type: "boolean",
|
|
59
|
+
description: "Install the packages (--no-install to only edit nuxt.config)",
|
|
60
|
+
default: true
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
63
|
+
async run({ args }) {
|
|
64
|
+
const logger = consola.withTag("add");
|
|
65
|
+
const modules = [...new Set(args._.map(String).map(resolveModuleName))];
|
|
66
|
+
const appDir = await resolveTargetApp(resolve(args.cwd), args.app).catch((error) => {
|
|
67
|
+
logger.error(error instanceof Error ? error.message : error);
|
|
68
|
+
return process.exit(1);
|
|
69
|
+
});
|
|
70
|
+
const configPath = findNuxtConfig(appDir);
|
|
71
|
+
if (args.install) {
|
|
72
|
+
logger.start(`Installing ${modules.join(", ")} in ${appDir}`);
|
|
73
|
+
await addDeps(modules, appDir);
|
|
74
|
+
}
|
|
75
|
+
const added = await addModulesToConfig(configPath, modules).catch((error) => {
|
|
76
|
+
logger.warn(`Could not edit ${configPath}: ${error instanceof Error ? error.message : error}`);
|
|
77
|
+
logger.info(`Add these to \`modules\` yourself:
|
|
78
|
+
${modules.map((name) => ` '${name}',`).join("\n")}`);
|
|
79
|
+
return void 0;
|
|
80
|
+
});
|
|
81
|
+
if (added) {
|
|
82
|
+
if (added.length) logger.success(`Added ${added.join(", ")} to ${configPath}`);
|
|
83
|
+
else logger.info(`Already in ${configPath}`);
|
|
84
|
+
}
|
|
85
|
+
for (const name of modules) {
|
|
86
|
+
const homepage = (await readPackage(join(appDir, "node_modules", name)).catch(() => void 0))?.homepage;
|
|
87
|
+
if (homepage) logger.info(`${name}: options, policies and migrations at ${homepage}`);
|
|
88
|
+
}
|
|
89
|
+
logger.info("Modules that add tables need a migration: run `pnpm db:generate` and commit it.");
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export { addModulesToConfig, add as default, resolveModuleName, resolveTargetApp };
|
|
@@ -1,35 +1,27 @@
|
|
|
1
1
|
import { defineCommand } from 'citty';
|
|
2
2
|
import consola from 'consola';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import { d as
|
|
7
|
-
import '
|
|
8
|
-
import 'node:
|
|
9
|
-
import 'node:fs/promises';
|
|
3
|
+
import { a as addPlatform } from '../shared/cli.DEhqG8Aw.mjs';
|
|
4
|
+
export { r as resolveAppScope } from '../shared/cli.DEhqG8Aw.mjs';
|
|
5
|
+
import { A as APP_TEMPLATES } from '../shared/cli.B8wGY3pU.mjs';
|
|
6
|
+
import { d as defineCommandArgs, c as templateArgs } from '../shared/cli.CU1tZqxU.mjs';
|
|
7
|
+
import { e as exitWith, a as appsDirArg } from '../shared/cli.CJ66durw.mjs';
|
|
8
|
+
import 'node:path';
|
|
10
9
|
import 'pkg-types';
|
|
10
|
+
import '../shared/cli.C-q4Gf2K.mjs';
|
|
11
11
|
import 'nypm';
|
|
12
|
+
import 'tinyexec';
|
|
13
|
+
import '../shared/cli.BLUxtpPi.mjs';
|
|
14
|
+
import 'node:fs';
|
|
15
|
+
import 'node:fs/promises';
|
|
16
|
+
import '../shared/cli.B9jOPxYC.mjs';
|
|
12
17
|
import 'giget';
|
|
13
18
|
import 'node:os';
|
|
19
|
+
import 'scule';
|
|
14
20
|
|
|
15
|
-
const APP_TEMPLATES = {
|
|
16
|
-
"web": ".starters/workspace/apps/web",
|
|
17
|
-
"web-standalone": ".starters/mobile-standalone/apps/web",
|
|
18
|
-
"mobile": ".starters/mobile/apps/mobile",
|
|
19
|
-
"desktop": ".starters/desktop/apps/desktop"
|
|
20
|
-
};
|
|
21
|
-
const isAppTemplate = (value) => value in APP_TEMPLATES;
|
|
22
|
-
const resolveAppScope = async (root) => {
|
|
23
|
-
for (const dir of await listDirs(join(root, "apps"))) {
|
|
24
|
-
const scope = packageScope((await readPackage(dir))?.name);
|
|
25
|
-
if (scope) return scope;
|
|
26
|
-
}
|
|
27
|
-
return packageScope((await readPackage(root))?.name);
|
|
28
|
-
};
|
|
29
21
|
const appCreate = defineCommand({
|
|
30
22
|
meta: {
|
|
31
23
|
name: "app:create",
|
|
32
|
-
description: "Add an app from a Frigear starter to
|
|
24
|
+
description: "Add an app from a Frigear starter to the workspace (same as platform add <template> <name>)"
|
|
33
25
|
},
|
|
34
26
|
args: defineCommandArgs({
|
|
35
27
|
name: {
|
|
@@ -39,42 +31,26 @@ const appCreate = defineCommand({
|
|
|
39
31
|
},
|
|
40
32
|
template: {
|
|
41
33
|
type: "string",
|
|
42
|
-
description: `App template: ${Object.keys(APP_TEMPLATES).join(", ")}`,
|
|
34
|
+
description: `App template: ${Object.keys(APP_TEMPLATES).join(", ")}, a template from frigear.templates or a giget source`,
|
|
43
35
|
default: "web"
|
|
44
36
|
},
|
|
37
|
+
...appsDirArg,
|
|
45
38
|
...templateArgs
|
|
46
39
|
}),
|
|
47
40
|
async run({ args }) {
|
|
48
41
|
const logger = consola.withTag("app:create");
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const appPath = join(root, "apps", name);
|
|
61
|
-
if (hasPackage(appPath)) {
|
|
62
|
-
logger.error(`App ${name} already exists at ${appPath}`);
|
|
63
|
-
return process.exit(1);
|
|
64
|
-
}
|
|
65
|
-
const scope = await resolveAppScope(root);
|
|
66
|
-
await downloadTemplateToDir({ template: repoSource(APP_TEMPLATES[template], args.ref), path: appPath }).catch((error) => {
|
|
67
|
-
logger.error(`Failed to create app ${name} at ${appPath}`);
|
|
68
|
-
logger.error(error instanceof Error ? error.message : error);
|
|
69
|
-
return process.exit(1);
|
|
70
|
-
});
|
|
71
|
-
await renamePackage(appPath, scope ? `${scope}/${name}` : name);
|
|
72
|
-
logger.success(`Created app ${name} at ${appPath}`);
|
|
73
|
-
if (args.install) {
|
|
74
|
-
logger.start("Installing dependencies");
|
|
75
|
-
await installDeps(root);
|
|
76
|
-
}
|
|
42
|
+
const platform = args.template in APP_TEMPLATES ? args.template : args.name;
|
|
43
|
+
await addPlatform({
|
|
44
|
+
cwd: args.cwd,
|
|
45
|
+
platform,
|
|
46
|
+
template: args.template,
|
|
47
|
+
name: args.name,
|
|
48
|
+
appsDir: args["apps-dir"],
|
|
49
|
+
ref: args.ref,
|
|
50
|
+
install: args.install,
|
|
51
|
+
logger
|
|
52
|
+
}).catch((error) => exitWith(logger, error));
|
|
77
53
|
}
|
|
78
54
|
});
|
|
79
55
|
|
|
80
|
-
export { APP_TEMPLATES, appCreate as default
|
|
56
|
+
export { APP_TEMPLATES, appCreate as default };
|
package/dist/chunks/init.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
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, h as hasPackage,
|
|
5
|
-
import { i as installDeps, r as runPackageScript } from '../shared/cli.
|
|
6
|
-
import { d as downloadTemplateToDir, r as repoSource } from '../shared/cli.
|
|
4
|
+
import { i as isEmptyDir, h as hasPackage, a as renamePackage, t as toPackageName, b as readPackage, d as defineCommandArgs, c as templateArgs } from '../shared/cli.CU1tZqxU.mjs';
|
|
5
|
+
import { i as installDeps, r as runPackageScript } from '../shared/cli.C-q4Gf2K.mjs';
|
|
6
|
+
import { d as downloadTemplateToDir, r as repoSource } from '../shared/cli.B9jOPxYC.mjs';
|
|
7
7
|
import 'scule';
|
|
8
8
|
import 'node:fs';
|
|
9
9
|
import 'node:fs/promises';
|
|
10
10
|
import 'pkg-types';
|
|
11
11
|
import 'nypm';
|
|
12
|
+
import 'tinyexec';
|
|
12
13
|
import 'giget';
|
|
13
14
|
import 'node:os';
|
|
14
15
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { defineCommand } from 'citty';
|
|
2
|
+
import consola from 'consola';
|
|
3
|
+
import { i as initPlatform } from '../shared/cli.BVDx1SIR.mjs';
|
|
4
|
+
import { P as PlatformError, d as defineCommandArgs } from '../shared/cli.CU1tZqxU.mjs';
|
|
5
|
+
import { p as passThroughArgs, e as exitWith, a as appsDirArg } from '../shared/cli.CJ66durw.mjs';
|
|
6
|
+
import 'node:fs';
|
|
7
|
+
import 'node:path';
|
|
8
|
+
import '../shared/cli.C-q4Gf2K.mjs';
|
|
9
|
+
import 'nypm';
|
|
10
|
+
import 'tinyexec';
|
|
11
|
+
import '../shared/cli.BLUxtpPi.mjs';
|
|
12
|
+
import 'node:fs/promises';
|
|
13
|
+
import '../shared/cli.B8wGY3pU.mjs';
|
|
14
|
+
import '../shared/cli.B9jOPxYC.mjs';
|
|
15
|
+
import 'giget';
|
|
16
|
+
import 'node:os';
|
|
17
|
+
import 'scule';
|
|
18
|
+
import 'pkg-types';
|
|
19
|
+
|
|
20
|
+
const init = defineCommand({
|
|
21
|
+
meta: {
|
|
22
|
+
name: "init",
|
|
23
|
+
description: "Set up a native target in an app: ios, android, apple-watch, tauri, or your platform's own (extra flags after --)"
|
|
24
|
+
},
|
|
25
|
+
args: defineCommandArgs({
|
|
26
|
+
target: {
|
|
27
|
+
type: "positional",
|
|
28
|
+
description: "Target: ios, android, apple-watch (watchos), tauri (desktop), or one from frigear.platforms",
|
|
29
|
+
required: true
|
|
30
|
+
},
|
|
31
|
+
app: {
|
|
32
|
+
type: "string",
|
|
33
|
+
description: "The app: a folder under the apps folder, or a path (default: the app you are in, or the only one with the target)"
|
|
34
|
+
},
|
|
35
|
+
...appsDirArg
|
|
36
|
+
}),
|
|
37
|
+
async run({ args, rawArgs }) {
|
|
38
|
+
const logger = consola.withTag("platform init");
|
|
39
|
+
const options = { cwd: args.cwd, target: args.target, appsDir: args["apps-dir"], args: passThroughArgs(rawArgs), logger };
|
|
40
|
+
try {
|
|
41
|
+
await initPlatform({ ...options, app: args.app });
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (error instanceof PlatformError && error.code === "APP_AMBIGUOUS" && process.stdin.isTTY && error.candidates?.length) {
|
|
44
|
+
const app = await consola.prompt(`Which app gets ${args.target}?`, { type: "select", options: error.candidates, cancel: "reject" });
|
|
45
|
+
await initPlatform({ ...options, app }).catch((retry) => exitWith(logger, retry));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
exitWith(logger, error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export { init as default };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { defineCommand } from 'citty';
|
|
2
|
+
import consola from 'consola';
|
|
3
|
+
import { relative } from 'node:path';
|
|
4
|
+
import { p as platformRegistry } from '../shared/cli.B8wGY3pU.mjs';
|
|
5
|
+
import { l as listWorkspaceApps } from '../shared/cli.BVDx1SIR.mjs';
|
|
6
|
+
import { f as findWorkspaceRoot, b as readPackage, r as resolveAppsDir, d as defineCommandArgs } from '../shared/cli.CU1tZqxU.mjs';
|
|
7
|
+
import { e as exitWith, a as appsDirArg } from '../shared/cli.CJ66durw.mjs';
|
|
8
|
+
import '../shared/cli.B9jOPxYC.mjs';
|
|
9
|
+
import 'giget';
|
|
10
|
+
import 'node:fs/promises';
|
|
11
|
+
import 'node:os';
|
|
12
|
+
import 'node:fs';
|
|
13
|
+
import '../shared/cli.C-q4Gf2K.mjs';
|
|
14
|
+
import 'nypm';
|
|
15
|
+
import 'tinyexec';
|
|
16
|
+
import '../shared/cli.BLUxtpPi.mjs';
|
|
17
|
+
import 'scule';
|
|
18
|
+
import 'pkg-types';
|
|
19
|
+
|
|
20
|
+
const list = defineCommand({
|
|
21
|
+
meta: {
|
|
22
|
+
name: "list",
|
|
23
|
+
description: "List the platforms, templates and targets, and the workspace's apps per platform"
|
|
24
|
+
},
|
|
25
|
+
args: defineCommandArgs({ ...appsDirArg }),
|
|
26
|
+
async run({ args }) {
|
|
27
|
+
const logger = consola.withTag("platform list");
|
|
28
|
+
const root = await findWorkspaceRoot(args.cwd);
|
|
29
|
+
const registry = platformRegistry(root ? await readPackage(root) : void 0);
|
|
30
|
+
const lines = ["Platforms:"];
|
|
31
|
+
for (const platform of Object.values(registry.platforms)) {
|
|
32
|
+
const targets = Object.keys(platform.targets ?? {});
|
|
33
|
+
lines.push(` ${platform.name}${platform.template ? ` (template ${platform.template})` : ""}${platform.description ? `: ${platform.description}` : ""}`);
|
|
34
|
+
if (targets.length) lines.push(` targets: ${targets.join(", ")}`);
|
|
35
|
+
}
|
|
36
|
+
lines.push("", `Templates: ${Object.keys(registry.templates).join(", ")}, or any giget source`);
|
|
37
|
+
if (root) {
|
|
38
|
+
const appsDir = await resolveAppsDir({ cwd: args.cwd, root, appsDir: args["apps-dir"] }).catch((error) => exitWith(logger, error));
|
|
39
|
+
const apps = await listWorkspaceApps(appsDir.dir, registry);
|
|
40
|
+
lines.push("", `Apps in ${relative(root, appsDir.dir) || "."}:`);
|
|
41
|
+
for (const app of apps) lines.push(` ${app.name}: ${app.platform?.name ?? "unknown platform"}`);
|
|
42
|
+
if (!apps.length) lines.push(" none yet");
|
|
43
|
+
}
|
|
44
|
+
logger.log(lines.join("\n"));
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export { list as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineCommand } from 'citty';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
|
-
import { t as toPackageName, f as findWorkspaceRoot, h as hasPackage,
|
|
4
|
-
import { d as downloadTemplateToDir } from '../shared/cli.
|
|
3
|
+
import { t as toPackageName, f as findWorkspaceRoot, h as hasPackage, a as renamePackage, d as defineCommandArgs, p as packageScope, b as readPackage } from '../shared/cli.CU1tZqxU.mjs';
|
|
4
|
+
import { d as downloadTemplateToDir } from '../shared/cli.B9jOPxYC.mjs';
|
|
5
5
|
import consola from 'consola';
|
|
6
6
|
import 'scule';
|
|
7
7
|
import 'node:fs';
|
|
@@ -3,16 +3,17 @@ import consola from 'consola';
|
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import { readFile } from 'node:fs/promises';
|
|
5
5
|
import { relative, extname, join, dirname } from 'node:path';
|
|
6
|
-
import { d as defineCommandArgs, f as findWorkspaceRoot } from '../shared/cli.
|
|
7
|
-
import { r as resolveLocalModule } from '../shared/cli.
|
|
6
|
+
import { d as defineCommandArgs, f as findWorkspaceRoot } from '../shared/cli.CU1tZqxU.mjs';
|
|
7
|
+
import { r as resolveLocalModule } from '../shared/cli.DAggATZw.mjs';
|
|
8
8
|
import { r as resolveArg, a as applyPlan, t as toPosix, p as printPlan, b as planChanges } from '../shared/cli.BLUxtpPi.mjs';
|
|
9
9
|
import 'scule';
|
|
10
10
|
import 'pkg-types';
|
|
11
|
-
import './
|
|
11
|
+
import './add2.mjs';
|
|
12
12
|
import 'magicast';
|
|
13
13
|
import 'magicast/helpers';
|
|
14
|
-
import '../shared/cli.
|
|
14
|
+
import '../shared/cli.C-q4Gf2K.mjs';
|
|
15
15
|
import 'nypm';
|
|
16
|
+
import 'tinyexec';
|
|
16
17
|
|
|
17
18
|
const runtimePluginStub = (name) => `import { defineNuxtPlugin } from '#imports'
|
|
18
19
|
|
|
@@ -3,17 +3,17 @@ import consola from 'consola';
|
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import { readFile } from 'node:fs/promises';
|
|
5
5
|
import { relative, join, extname, sep, dirname } from 'node:path';
|
|
6
|
-
import { w as workspaceGlobs } from '../shared/cli.
|
|
7
|
-
import {
|
|
8
|
-
import { r as resolveLocalModule } from '../shared/cli.CybmnaqF.mjs';
|
|
6
|
+
import { d as defineCommandArgs, f as findWorkspaceRoot, w as workspaceGlobs, b as readPackage } from '../shared/cli.CU1tZqxU.mjs';
|
|
7
|
+
import { r as resolveLocalModule } from '../shared/cli.DAggATZw.mjs';
|
|
9
8
|
import { r as resolveArg, a as applyPlan, p as printPlan, t as toPosix, f as findNuxtRoot, b as planChanges, w as workspaceFiles } from '../shared/cli.BLUxtpPi.mjs';
|
|
10
9
|
import 'scule';
|
|
11
10
|
import 'pkg-types';
|
|
12
|
-
import './
|
|
11
|
+
import './add2.mjs';
|
|
13
12
|
import 'magicast';
|
|
14
13
|
import 'magicast/helpers';
|
|
15
|
-
import '../shared/cli.
|
|
14
|
+
import '../shared/cli.C-q4Gf2K.mjs';
|
|
16
15
|
import 'nypm';
|
|
16
|
+
import 'tinyexec';
|
|
17
17
|
|
|
18
18
|
const matchesWorkspaceGlobs = (path, globs) => globs.some((glob) => {
|
|
19
19
|
const pattern = glob.replace(/\/+$/, "").split("/").map((part) => part === "**" ? ".*" : part.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*")).join("/");
|
|
@@ -3,8 +3,7 @@ import consola from 'consola';
|
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import { readFile } from 'node:fs/promises';
|
|
5
5
|
import { relative, join, dirname, basename } from 'node:path';
|
|
6
|
-
import {
|
|
7
|
-
import { d as defineCommandArgs, f as findWorkspaceRoot, a as readPackage, p as packageScope } from '../shared/cli.Cfkcp0w9.mjs';
|
|
6
|
+
import { d as defineCommandArgs, f as findWorkspaceRoot, e as workspacePackageDirs, b as readPackage, p as packageScope } from '../shared/cli.CU1tZqxU.mjs';
|
|
8
7
|
import { r as resolveArg, a as applyPlan, p as printPlan, t as toPosix, b as planChanges } from '../shared/cli.BLUxtpPi.mjs';
|
|
9
8
|
import 'scule';
|
|
10
9
|
import 'pkg-types';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineCommand } from 'citty';
|
|
2
|
+
|
|
3
|
+
const index = defineCommand({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "platform",
|
|
6
|
+
description: "Add apps of a platform to the workspace and set up their native targets"
|
|
7
|
+
},
|
|
8
|
+
subCommands: {
|
|
9
|
+
add: () => import('./add.mjs').then((module) => module.default),
|
|
10
|
+
init: () => import('./init2.mjs').then((module) => module.default),
|
|
11
|
+
list: () => import('./list.mjs').then((module) => module.default)
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export { index as default };
|