@frigear-nu/cli 0.2.8 → 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 +8 -4
- package/dist/chunks/add.mjs +3 -3
- package/dist/chunks/add2.mjs +53 -12
- package/dist/chunks/app-create.mjs +4 -4
- package/dist/chunks/env.mjs +1 -1
- package/dist/chunks/info.mjs +98 -0
- package/dist/chunks/init.mjs +1 -1
- package/dist/chunks/init2.mjs +3 -3
- package/dist/chunks/list.mjs +3 -3
- package/dist/chunks/list2.mjs +75 -0
- package/dist/chunks/module-create.mjs +3 -3
- package/dist/chunks/module-folder.mjs +6 -4
- package/dist/chunks/module-move.mjs +6 -4
- package/dist/chunks/module.mjs +18 -0
- package/dist/chunks/package-rename.mjs +1 -1
- package/dist/chunks/upgrade.mjs +163 -24
- package/dist/cli.mjs +2 -1
- package/dist/index.d.mts +60 -3
- package/dist/index.d.ts +60 -3
- package/dist/index.mjs +6 -4
- package/dist/shared/{cli.BgaCK7CK.mjs → cli.A6PoFRmM.mjs} +1 -1
- package/dist/shared/{cli.CsVNx740.mjs → cli.BCgeZaNi.mjs} +1 -1
- package/dist/shared/cli.DLJLsgDV.mjs +89 -0
- package/dist/shared/cli.Dh9sTqNx.mjs +22 -0
- package/dist/shared/{cli.DM-mHY0i.mjs → cli.Ds_WnWsn.mjs} +1 -1
- package/dist/shared/cli.IEy-SSS4.mjs +44 -0
- package/dist/shared/{cli.CgfNXZ_5.mjs → cli._jTVAy9s.mjs} +1 -1
- package/package.json +1 -1
- package/dist/shared/cli.BoJY7u-i.mjs +0 -30
package/README.md
CHANGED
|
@@ -14,14 +14,18 @@ pnpx @frigear-nu/cli --help
|
|
|
14
14
|
| `platform init <ios\|android\|apple-watch\|tauri\|...> [--app <name>]` | Sets up a native target in an app through its own tooling. |
|
|
15
15
|
| `platform list` | Platforms, templates, targets and the workspace's apps. |
|
|
16
16
|
| `app:create <name> --template <web\|web-standalone\|mobile\|desktop>` | `platform add <template> <name>`. |
|
|
17
|
-
| `module
|
|
18
|
-
| `
|
|
17
|
+
| `module list [--search <text>] [--json]` | Published Frigear modules, ✔ for the ones the app has, and third-party packages with the `frigear-module` keyword in their own section. |
|
|
18
|
+
| `module info <module> [--json]` | Version, docs, the modules it pulls in, optional integrations and the install command. `users` or a full name such as `@acme/thing`. |
|
|
19
|
+
| `module add [module...] [--app <app>] [--all]` | `pnpm add` in the app and adds the modules to its `nuxt.config`; without names, a multi-select list of Frigear modules (`--all` adds third-party ones, marked). `add` is the same command. |
|
|
20
|
+
| `module create <name> [--scope @acme]` | Scaffolds a Nuxt module in `packages/<name>`. |
|
|
19
21
|
| `package:rename <package> <new-name> [--dir]` | Renames a workspace package in manifests, `pnpm-workspace.yaml`, imports and config. |
|
|
20
|
-
| `module
|
|
21
|
-
| `module
|
|
22
|
+
| `module folder <module> [--runtime]` | Turns `modules/foo.ts` into `modules/foo/index.ts`. |
|
|
23
|
+
| `module move <module> <destination> [--name <name>]` | Moves a local module or package folder and fixes relative paths. |
|
|
22
24
|
|
|
23
25
|
`addPlatform`, `initPlatform` and `definePlatform` are exported for use from code.
|
|
24
26
|
|
|
27
|
+
`module:create`, `module:folder` and `module:move` still work, with a deprecation warning.
|
|
28
|
+
|
|
25
29
|
The three refactoring commands take `--dry-run` to print the changes without writing them.
|
|
26
30
|
|
|
27
31
|
Starters are downloaded from `Frigear-nu/frigear-nu` with [giget](https://github.com/unjs/giget) (`--ref` picks a branch
|
package/dist/chunks/add.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { defineCommand } from 'citty';
|
|
2
2
|
import consola from 'consola';
|
|
3
3
|
import { relative } from 'node:path';
|
|
4
|
-
import { a as addPlatform } from '../shared/cli.
|
|
5
|
-
import { P as PlatformError, t as toPackageName, d as defineCommandArgs, c as templateArgs } from '../shared/cli.
|
|
6
|
-
import { e as exitWith, a as appsDirArg } from '../shared/cli.
|
|
4
|
+
import { a as addPlatform } from '../shared/cli._jTVAy9s.mjs';
|
|
5
|
+
import { P as PlatformError, t as toPackageName, d as defineCommandArgs, c as templateArgs } from '../shared/cli.A6PoFRmM.mjs';
|
|
6
|
+
import { e as exitWith, a as appsDirArg } from '../shared/cli.Ds_WnWsn.mjs';
|
|
7
7
|
import 'pkg-types';
|
|
8
8
|
import '../shared/cli.C-q4Gf2K.mjs';
|
|
9
9
|
import 'nypm';
|
package/dist/chunks/add2.mjs
CHANGED
|
@@ -5,15 +5,16 @@ 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 { b as readPackage, d as defineCommandArgs, f as findWorkspaceRoot, l as listDirs } from '../shared/cli.
|
|
8
|
+
import { b as readPackage, d as defineCommandArgs, f as findWorkspaceRoot, l as listDirs } from '../shared/cli.A6PoFRmM.mjs';
|
|
9
9
|
import { a as addDeps } from '../shared/cli.C-q4Gf2K.mjs';
|
|
10
|
+
import { r as resolveModuleName, c as isFirstParty, i as isModuleName, b as shortModuleName, s as searchModules, m as moduleEntry, f as fetchModuleInfo } from '../shared/cli.DLJLsgDV.mjs';
|
|
10
11
|
import 'scule';
|
|
11
12
|
import 'pkg-types';
|
|
12
13
|
import 'nypm';
|
|
13
14
|
import 'tinyexec';
|
|
15
|
+
import '../shared/cli.Dh9sTqNx.mjs';
|
|
14
16
|
|
|
15
17
|
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
18
|
const findNuxtConfig = (dir) => NUXT_CONFIGS.map((file) => join(dir, file)).find(existsSync);
|
|
18
19
|
const resolveTargetApp = async (cwd, app) => {
|
|
19
20
|
if (app) {
|
|
@@ -39,6 +40,32 @@ const addModulesToConfig = async (configPath, modules) => {
|
|
|
39
40
|
`, "utf-8");
|
|
40
41
|
return added;
|
|
41
42
|
};
|
|
43
|
+
const appDependencies = async (appDir) => {
|
|
44
|
+
const pkg = await readPackage(appDir).catch(() => void 0);
|
|
45
|
+
return { ...pkg?.devDependencies, ...pkg?.dependencies };
|
|
46
|
+
};
|
|
47
|
+
const pickModules = async (installed, { all = false } = {}) => {
|
|
48
|
+
if (!process.stdin.isTTY) throw new Error("Pass the modules to add, e.g. `add forms users`, or run it in a terminal to pick them.");
|
|
49
|
+
const available = (await searchModules()).filter((mod) => !installed[mod.name] && (all || mod.firstParty));
|
|
50
|
+
if (!available.length) throw new Error(`Every published ${all ? "" : "Frigear "}module is already in this app.`);
|
|
51
|
+
const picked = await consola.prompt("Modules to add (space to select, enter to install)", {
|
|
52
|
+
type: "multiselect",
|
|
53
|
+
required: true,
|
|
54
|
+
cancel: "reject",
|
|
55
|
+
options: available.map((mod) => ({
|
|
56
|
+
value: mod.name,
|
|
57
|
+
label: mod.firstParty ? shortModuleName(mod.name) : mod.name,
|
|
58
|
+
hint: mod.firstParty ? mod.description : `third-party, not reviewed by Frigear${mod.description ? ` \xB7 ${mod.description}` : ""}`
|
|
59
|
+
}))
|
|
60
|
+
});
|
|
61
|
+
return picked.map((item) => typeof item === "string" ? item : item.value);
|
|
62
|
+
};
|
|
63
|
+
const resolveEntries = async (modules, appDir) => Promise.all(modules.map(async (name) => {
|
|
64
|
+
const installed = await readPackage(join(appDir, "node_modules", name)).catch(() => void 0);
|
|
65
|
+
if (installed) return moduleEntry({ name, exports: installed.exports });
|
|
66
|
+
if (isFirstParty(name)) return name;
|
|
67
|
+
return (await fetchModuleInfo(name).catch(() => void 0))?.entry ?? name;
|
|
68
|
+
}));
|
|
42
69
|
const add = defineCommand({
|
|
43
70
|
meta: {
|
|
44
71
|
name: "add",
|
|
@@ -47,8 +74,8 @@ const add = defineCommand({
|
|
|
47
74
|
args: defineCommandArgs({
|
|
48
75
|
modules: {
|
|
49
76
|
type: "positional",
|
|
50
|
-
description: "Modules to add e.g. forms or @frigear-nu/forms",
|
|
51
|
-
required:
|
|
77
|
+
description: "Modules to add e.g. forms or @frigear-nu/forms (none: pick from a list)",
|
|
78
|
+
required: false
|
|
52
79
|
},
|
|
53
80
|
app: {
|
|
54
81
|
type: "string",
|
|
@@ -58,36 +85,50 @@ const add = defineCommand({
|
|
|
58
85
|
type: "boolean",
|
|
59
86
|
description: "Install the packages (--no-install to only edit nuxt.config)",
|
|
60
87
|
default: true
|
|
88
|
+
},
|
|
89
|
+
all: {
|
|
90
|
+
type: "boolean",
|
|
91
|
+
description: "Also offer third-party modules (packages with the frigear-module keyword) in the list",
|
|
92
|
+
default: false
|
|
61
93
|
}
|
|
62
94
|
}),
|
|
63
95
|
async run({ args }) {
|
|
64
96
|
const logger = consola.withTag("add");
|
|
65
|
-
const
|
|
66
|
-
const appDir = await resolveTargetApp(resolve(args.cwd), args.app).catch((error) => {
|
|
97
|
+
const fail = (error) => {
|
|
67
98
|
logger.error(error instanceof Error ? error.message : error);
|
|
68
99
|
return process.exit(1);
|
|
69
|
-
}
|
|
100
|
+
};
|
|
101
|
+
const appDir = await resolveTargetApp(resolve(args.cwd), args.app).catch(fail);
|
|
70
102
|
const configPath = findNuxtConfig(appDir);
|
|
103
|
+
const named = args._.map(String);
|
|
104
|
+
const modules = [...new Set(named.length ? named.map(resolveModuleName) : await pickModules(await appDependencies(appDir), { all: args.all }).catch(fail))];
|
|
105
|
+
const thirdParty = modules.filter((name) => !isFirstParty(name));
|
|
106
|
+
if (thirdParty.length)
|
|
107
|
+
logger.warn(`Third-party, not reviewed by Frigear: ${thirdParty.join(", ")}. Installing runs its code in your app.`);
|
|
71
108
|
if (args.install) {
|
|
72
109
|
logger.start(`Installing ${modules.join(", ")} in ${appDir}`);
|
|
73
110
|
await addDeps(modules, appDir);
|
|
74
111
|
}
|
|
75
|
-
const
|
|
112
|
+
const entries = await resolveEntries(modules, appDir);
|
|
113
|
+
const added = await addModulesToConfig(configPath, entries).catch((error) => {
|
|
76
114
|
logger.warn(`Could not edit ${configPath}: ${error instanceof Error ? error.message : error}`);
|
|
77
115
|
logger.info(`Add these to \`modules\` yourself:
|
|
78
|
-
${
|
|
116
|
+
${entries.map((name) => ` '${name}',`).join("\n")}`);
|
|
79
117
|
return void 0;
|
|
80
118
|
});
|
|
81
119
|
if (added) {
|
|
82
120
|
if (added.length) logger.success(`Added ${added.join(", ")} to ${configPath}`);
|
|
83
121
|
else logger.info(`Already in ${configPath}`);
|
|
84
122
|
}
|
|
123
|
+
const dependencies = await appDependencies(appDir);
|
|
85
124
|
for (const name of modules) {
|
|
86
|
-
const
|
|
87
|
-
if (homepage) logger.info(`${name}: options, policies and migrations at ${homepage}`);
|
|
125
|
+
const pkg = await readPackage(join(appDir, "node_modules", name)).catch(() => void 0);
|
|
126
|
+
if (pkg?.homepage) logger.info(`${name}: options, policies and migrations at ${pkg.homepage}`);
|
|
127
|
+
const optional = Object.keys(pkg?.peerDependencies ?? {}).filter((peer) => isModuleName(peer) && !dependencies[peer] && !modules.includes(peer));
|
|
128
|
+
if (optional.length) logger.info(`${name} works with: ${optional.map(shortModuleName).join(", ")} (\`module add <name>\`)`);
|
|
88
129
|
}
|
|
89
130
|
logger.info("Modules that add tables need a migration: run `pnpm db:generate` and commit it.");
|
|
90
131
|
}
|
|
91
132
|
});
|
|
92
133
|
|
|
93
|
-
export { addModulesToConfig, add as default, resolveModuleName, resolveTargetApp };
|
|
134
|
+
export { addModulesToConfig, appDependencies, add as default, findNuxtConfig, pickModules, resolveModuleName, resolveTargetApp };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { defineCommand } from 'citty';
|
|
2
2
|
import consola from 'consola';
|
|
3
|
-
import { a as addPlatform } from '../shared/cli.
|
|
4
|
-
export { r as resolveAppScope } from '../shared/cli.
|
|
3
|
+
import { a as addPlatform } from '../shared/cli._jTVAy9s.mjs';
|
|
4
|
+
export { r as resolveAppScope } from '../shared/cli._jTVAy9s.mjs';
|
|
5
5
|
import { A as APP_TEMPLATES } from '../shared/cli.DnhGPz3G.mjs';
|
|
6
|
-
import { d as defineCommandArgs, c as templateArgs } from '../shared/cli.
|
|
7
|
-
import { e as exitWith, a as appsDirArg } from '../shared/cli.
|
|
6
|
+
import { d as defineCommandArgs, c as templateArgs } from '../shared/cli.A6PoFRmM.mjs';
|
|
7
|
+
import { e as exitWith, a as appsDirArg } from '../shared/cli.Ds_WnWsn.mjs';
|
|
8
8
|
import 'node:path';
|
|
9
9
|
import 'pkg-types';
|
|
10
10
|
import '../shared/cli.C-q4Gf2K.mjs';
|
package/dist/chunks/env.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineCommand } from 'citty';
|
|
2
2
|
import consola from 'consola';
|
|
3
3
|
import { p as prepareEnv, d as describeEnvResult } from '../shared/cli.s0Wk6nL9.mjs';
|
|
4
|
-
import { f as findWorkspaceRoot, d as defineCommandArgs } from '../shared/cli.
|
|
4
|
+
import { f as findWorkspaceRoot, d as defineCommandArgs } from '../shared/cli.A6PoFRmM.mjs';
|
|
5
5
|
import 'node:fs';
|
|
6
6
|
import 'node:fs/promises';
|
|
7
7
|
import 'node:crypto';
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { defineCommand } from 'citty';
|
|
2
|
+
import consola from 'consola';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { a as findModule, i as isModuleName, c as isFirstParty, b as shortModuleName } from '../shared/cli.DLJLsgDV.mjs';
|
|
5
|
+
import { d as defineCommandArgs } from '../shared/cli.A6PoFRmM.mjs';
|
|
6
|
+
import { resolveTargetApp, appDependencies } from './add2.mjs';
|
|
7
|
+
import '../shared/cli.Dh9sTqNx.mjs';
|
|
8
|
+
import 'scule';
|
|
9
|
+
import 'node:fs';
|
|
10
|
+
import 'node:fs/promises';
|
|
11
|
+
import 'pkg-types';
|
|
12
|
+
import 'magicast';
|
|
13
|
+
import 'magicast/helpers';
|
|
14
|
+
import '../shared/cli.C-q4Gf2K.mjs';
|
|
15
|
+
import 'nypm';
|
|
16
|
+
import 'tinyexec';
|
|
17
|
+
|
|
18
|
+
const info = defineCommand({
|
|
19
|
+
meta: {
|
|
20
|
+
name: "info",
|
|
21
|
+
description: "Show a module: description, version, docs, the modules it pulls in and how to install it"
|
|
22
|
+
},
|
|
23
|
+
args: defineCommandArgs({
|
|
24
|
+
module: {
|
|
25
|
+
type: "positional",
|
|
26
|
+
description: "The module: users, or a full package name such as @frigear-nu/users or @acme/thing",
|
|
27
|
+
required: true
|
|
28
|
+
},
|
|
29
|
+
app: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "App to compare the installed version with: a path, or a folder under apps/"
|
|
32
|
+
},
|
|
33
|
+
json: {
|
|
34
|
+
type: "boolean",
|
|
35
|
+
description: "Print JSON",
|
|
36
|
+
default: false
|
|
37
|
+
}
|
|
38
|
+
}),
|
|
39
|
+
async run({ args }) {
|
|
40
|
+
const logger = consola.withTag("module info");
|
|
41
|
+
const info = await findModule(args.module).catch((error) => {
|
|
42
|
+
logger.error(error instanceof Error ? error.message : error);
|
|
43
|
+
return process.exit(1);
|
|
44
|
+
});
|
|
45
|
+
if (!info) {
|
|
46
|
+
logger.error(`No published module named ${args.module}. \`module list\` shows the ones there are.`);
|
|
47
|
+
return process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
const appDir = await resolveTargetApp(resolve(args.cwd), args.app).catch(() => void 0);
|
|
50
|
+
const installed = appDir ? (await appDependencies(appDir))[info.name] : void 0;
|
|
51
|
+
const pullsIn = Object.keys(info.dependencies ?? {}).filter((name) => isModuleName(name));
|
|
52
|
+
const worksWith = Object.keys(info.peerDependencies ?? {}).filter((name) => isModuleName(name));
|
|
53
|
+
if (args.json) {
|
|
54
|
+
process.stdout.write(`${JSON.stringify({
|
|
55
|
+
name: info.name,
|
|
56
|
+
firstParty: isFirstParty(info.name),
|
|
57
|
+
version: info.version,
|
|
58
|
+
description: info.description,
|
|
59
|
+
entry: info.entry,
|
|
60
|
+
installed,
|
|
61
|
+
homepage: info.homepage,
|
|
62
|
+
repository: info.repositoryUrl,
|
|
63
|
+
license: info.license,
|
|
64
|
+
deprecated: info.deprecated,
|
|
65
|
+
pullsIn,
|
|
66
|
+
worksWith
|
|
67
|
+
}, null, 2)}
|
|
68
|
+
`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const short = shortModuleName(info.name);
|
|
72
|
+
const rows = [
|
|
73
|
+
["Publisher", isFirstParty(info.name) ? "Frigear" : "third-party, not reviewed by Frigear"],
|
|
74
|
+
["Version", info.version],
|
|
75
|
+
["Deprecated", info.deprecated],
|
|
76
|
+
["Installed", appDir ? installed ?? "no" : void 0],
|
|
77
|
+
["Docs", info.homepage],
|
|
78
|
+
["Repository", info.repositoryUrl],
|
|
79
|
+
["License", info.license],
|
|
80
|
+
["nuxt.config", info.entry !== info.name ? `'${info.entry}'` : void 0],
|
|
81
|
+
["Pulls in", pullsIn.length ? pullsIn.map(shortModuleName).join(", ") : void 0],
|
|
82
|
+
["Works with", worksWith.length ? `${worksWith.map(shortModuleName).join(", ")} (optional)` : void 0]
|
|
83
|
+
];
|
|
84
|
+
const shown = rows.filter((row) => Boolean(row[1]));
|
|
85
|
+
const width = Math.max(...shown.map(([key]) => key.length));
|
|
86
|
+
process.stdout.write(`${[
|
|
87
|
+
`${info.name}${info.description ? `
|
|
88
|
+
${info.description}` : ""}`,
|
|
89
|
+
"",
|
|
90
|
+
...shown.map(([key, value]) => `${`${key}:`.padEnd(width + 1)} ${value}`),
|
|
91
|
+
"",
|
|
92
|
+
info.deprecated ? "Deprecated: not for new apps." : `Install: pnpx @frigear-nu/cli module add ${short}`
|
|
93
|
+
].join("\n")}
|
|
94
|
+
`);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
export { info as default };
|
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, h as hasPackage, a as renamePackage, t as toPackageName, b as readPackage, d as defineCommandArgs, c as templateArgs } 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.A6PoFRmM.mjs';
|
|
5
5
|
import { i as installDeps, r as runPackageScript } from '../shared/cli.C-q4Gf2K.mjs';
|
|
6
6
|
import { d as downloadTemplateToDir, r as repoSource } from '../shared/cli.B9jOPxYC.mjs';
|
|
7
7
|
import 'scule';
|
package/dist/chunks/init2.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineCommand } from 'citty';
|
|
2
2
|
import consola from 'consola';
|
|
3
|
-
import { i as initPlatform } from '../shared/cli.
|
|
4
|
-
import { P as PlatformError, d as defineCommandArgs } from '../shared/cli.
|
|
5
|
-
import { p as passThroughArgs, e as exitWith, a as appsDirArg } from '../shared/cli.
|
|
3
|
+
import { i as initPlatform } from '../shared/cli.BCgeZaNi.mjs';
|
|
4
|
+
import { P as PlatformError, d as defineCommandArgs } from '../shared/cli.A6PoFRmM.mjs';
|
|
5
|
+
import { p as passThroughArgs, e as exitWith, a as appsDirArg } from '../shared/cli.Ds_WnWsn.mjs';
|
|
6
6
|
import 'node:fs';
|
|
7
7
|
import 'node:path';
|
|
8
8
|
import '../shared/cli.C-q4Gf2K.mjs';
|
package/dist/chunks/list.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import { defineCommand } from 'citty';
|
|
|
2
2
|
import consola from 'consola';
|
|
3
3
|
import { relative } from 'node:path';
|
|
4
4
|
import { p as platformRegistry } from '../shared/cli.DnhGPz3G.mjs';
|
|
5
|
-
import { l as listWorkspaceApps } from '../shared/cli.
|
|
6
|
-
import { f as findWorkspaceRoot, b as readPackage, r as resolveAppsDir, d as defineCommandArgs } from '../shared/cli.
|
|
7
|
-
import { e as exitWith, a as appsDirArg } from '../shared/cli.
|
|
5
|
+
import { l as listWorkspaceApps } from '../shared/cli.BCgeZaNi.mjs';
|
|
6
|
+
import { f as findWorkspaceRoot, b as readPackage, r as resolveAppsDir, d as defineCommandArgs } from '../shared/cli.A6PoFRmM.mjs';
|
|
7
|
+
import { e as exitWith, a as appsDirArg } from '../shared/cli.Ds_WnWsn.mjs';
|
|
8
8
|
import '../shared/cli.B9jOPxYC.mjs';
|
|
9
9
|
import 'giget';
|
|
10
10
|
import 'node:fs/promises';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { defineCommand } from 'citty';
|
|
2
|
+
import consola from 'consola';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { s as searchModules, F as FIRST_PARTY_SCOPE, b as shortModuleName } from '../shared/cli.DLJLsgDV.mjs';
|
|
5
|
+
import { d as defineCommandArgs } from '../shared/cli.A6PoFRmM.mjs';
|
|
6
|
+
import { resolveTargetApp, appDependencies } from './add2.mjs';
|
|
7
|
+
import '../shared/cli.Dh9sTqNx.mjs';
|
|
8
|
+
import 'scule';
|
|
9
|
+
import 'node:fs';
|
|
10
|
+
import 'node:fs/promises';
|
|
11
|
+
import 'pkg-types';
|
|
12
|
+
import 'magicast';
|
|
13
|
+
import 'magicast/helpers';
|
|
14
|
+
import '../shared/cli.C-q4Gf2K.mjs';
|
|
15
|
+
import 'nypm';
|
|
16
|
+
import 'tinyexec';
|
|
17
|
+
|
|
18
|
+
const list = defineCommand({
|
|
19
|
+
meta: {
|
|
20
|
+
name: "list",
|
|
21
|
+
description: "List the Frigear modules on npm (first-party, and third-party ones with the frigear-module keyword)"
|
|
22
|
+
},
|
|
23
|
+
args: defineCommandArgs({
|
|
24
|
+
search: {
|
|
25
|
+
type: "string",
|
|
26
|
+
description: "Only modules whose name or description contains this text"
|
|
27
|
+
},
|
|
28
|
+
app: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "App to mark installed modules in: a path, or a folder under apps/"
|
|
31
|
+
},
|
|
32
|
+
json: {
|
|
33
|
+
type: "boolean",
|
|
34
|
+
description: "Print JSON",
|
|
35
|
+
default: false
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
async run({ args }) {
|
|
39
|
+
const logger = consola.withTag("module list");
|
|
40
|
+
const modules = await searchModules(args.search).catch((error) => {
|
|
41
|
+
logger.error(error instanceof Error ? error.message : error);
|
|
42
|
+
return process.exit(1);
|
|
43
|
+
});
|
|
44
|
+
const appDir = await resolveTargetApp(resolve(args.cwd), args.app).catch(() => void 0);
|
|
45
|
+
const installed = appDir ? await appDependencies(appDir) : {};
|
|
46
|
+
if (args.json) {
|
|
47
|
+
process.stdout.write(`${JSON.stringify(modules.map((mod) => ({ ...mod, installed: installed[mod.name] })), null, 2)}
|
|
48
|
+
`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (!modules.length) {
|
|
52
|
+
logger.info(args.search ? `No modules match "${args.search}".` : "No modules found.");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const label = (name) => shortModuleName(name);
|
|
56
|
+
const width = Math.max(...modules.map((mod) => label(mod.name).length));
|
|
57
|
+
const versionWidth = Math.max(...modules.map((mod) => mod.version.length));
|
|
58
|
+
const columns = process.stdout.columns || 120;
|
|
59
|
+
const line = (mod) => {
|
|
60
|
+
const text = [installed[mod.name] ? "\u2714" : " ", label(mod.name).padEnd(width), mod.version.padEnd(versionWidth), mod.description ?? ""].join(" ").trimEnd();
|
|
61
|
+
return text.length > columns ? `${text.slice(0, columns - 1)}\u2026` : text;
|
|
62
|
+
};
|
|
63
|
+
const firstParty = modules.filter((mod) => mod.firstParty);
|
|
64
|
+
const thirdParty = modules.filter((mod) => !mod.firstParty);
|
|
65
|
+
const sections = [
|
|
66
|
+
...firstParty.length ? [`Frigear (${FIRST_PARTY_SCOPE})`, ...firstParty.map(line), ""] : [],
|
|
67
|
+
...thirdParty.length ? ["Third-party (frigear-module keyword, not reviewed by Frigear)", ...thirdParty.map(line), ""] : []
|
|
68
|
+
];
|
|
69
|
+
process.stdout.write(`${sections.join("\n")}
|
|
70
|
+
`);
|
|
71
|
+
logger.info(`${modules.length} module${modules.length === 1 ? "" : "s"}${appDir ? ", \u2714 = in this app" : ""}. Details: \`module info <name>\`, install: \`module add [names...]\` (\`--all\` offers third-party ones too).`);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export { list as default };
|
|
@@ -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, a as renamePackage, d as defineCommandArgs, p as packageScope, b as readPackage } 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.A6PoFRmM.mjs';
|
|
4
4
|
import { d as downloadTemplateToDir } from '../shared/cli.B9jOPxYC.mjs';
|
|
5
5
|
import consola from 'consola';
|
|
6
6
|
import 'scule';
|
|
@@ -16,7 +16,7 @@ const resolveModuleScope = async (root, scope) => {
|
|
|
16
16
|
};
|
|
17
17
|
const moduleCreate = defineCommand({
|
|
18
18
|
meta: {
|
|
19
|
-
name: "
|
|
19
|
+
name: "create",
|
|
20
20
|
description: "Create a new Nuxt Module"
|
|
21
21
|
},
|
|
22
22
|
args: defineCommandArgs({
|
|
@@ -41,7 +41,7 @@ const moduleCreate = defineCommand({
|
|
|
41
41
|
}
|
|
42
42
|
}),
|
|
43
43
|
async run({ args }) {
|
|
44
|
-
const logger = consola.withTag("module
|
|
44
|
+
const logger = consola.withTag("module create");
|
|
45
45
|
const { template } = args;
|
|
46
46
|
const name = toPackageName(args.name);
|
|
47
47
|
const root = await findWorkspaceRoot(args.cwd) ?? resolve(args.cwd);
|
|
@@ -3,7 +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, extname, join, dirname } from 'node:path';
|
|
6
|
-
import { d as defineCommandArgs, f as findWorkspaceRoot } from '../shared/cli.
|
|
6
|
+
import { d as defineCommandArgs, f as findWorkspaceRoot } from '../shared/cli.A6PoFRmM.mjs';
|
|
7
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';
|
|
@@ -14,6 +14,8 @@ import 'magicast/helpers';
|
|
|
14
14
|
import '../shared/cli.C-q4Gf2K.mjs';
|
|
15
15
|
import 'nypm';
|
|
16
16
|
import 'tinyexec';
|
|
17
|
+
import '../shared/cli.DLJLsgDV.mjs';
|
|
18
|
+
import '../shared/cli.Dh9sTqNx.mjs';
|
|
17
19
|
|
|
18
20
|
const runtimePluginStub = (name) => `import { defineNuxtPlugin } from '#imports'
|
|
19
21
|
|
|
@@ -47,7 +49,7 @@ const planModuleFolder = async (options) => {
|
|
|
47
49
|
};
|
|
48
50
|
const moduleFolder = defineCommand({
|
|
49
51
|
meta: {
|
|
50
|
-
name: "
|
|
52
|
+
name: "folder",
|
|
51
53
|
description: "Turn a single-file local module (modules/foo.ts) into a folder module (modules/foo/index.ts)"
|
|
52
54
|
},
|
|
53
55
|
args: defineCommandArgs({
|
|
@@ -72,14 +74,14 @@ const moduleFolder = defineCommand({
|
|
|
72
74
|
}
|
|
73
75
|
}),
|
|
74
76
|
async run({ args }) {
|
|
75
|
-
const logger = consola.withTag("module
|
|
77
|
+
const logger = consola.withTag("module folder");
|
|
76
78
|
const result = await planModuleFolder({ cwd: resolveArg(process.cwd(), args.cwd), module: args.module, app: args.app, runtime: args.runtime }).catch((error) => {
|
|
77
79
|
logger.error(error instanceof Error ? error.message : error);
|
|
78
80
|
return process.exit(1);
|
|
79
81
|
});
|
|
80
82
|
if (!args.dryRun) await applyPlan(result.plan);
|
|
81
83
|
logger.success(`${args.dryRun ? "Would move" : "Moved"} ${result.module.name} to ${toPosix(relative(result.root, result.index))}`);
|
|
82
|
-
printPlan(result.plan, "module
|
|
84
|
+
printPlan(result.plan, "module folder", {
|
|
83
85
|
dryRun: args.dryRun,
|
|
84
86
|
next: ["Restart `nuxi dev` (or run `nuxi prepare`): Nuxt loads modules/<name>/index.ts like modules/<name>.ts"]
|
|
85
87
|
});
|
|
@@ -3,7 +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, extname, sep, dirname } from 'node:path';
|
|
6
|
-
import { d as defineCommandArgs, f as findWorkspaceRoot,
|
|
6
|
+
import { d as defineCommandArgs, f as findWorkspaceRoot, e as workspaceGlobs, b as readPackage } from '../shared/cli.A6PoFRmM.mjs';
|
|
7
7
|
import { r as resolveLocalModule } from '../shared/cli.DAggATZw.mjs';
|
|
8
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';
|
|
9
9
|
import 'scule';
|
|
@@ -14,6 +14,8 @@ import 'magicast/helpers';
|
|
|
14
14
|
import '../shared/cli.C-q4Gf2K.mjs';
|
|
15
15
|
import 'nypm';
|
|
16
16
|
import 'tinyexec';
|
|
17
|
+
import '../shared/cli.DLJLsgDV.mjs';
|
|
18
|
+
import '../shared/cli.Dh9sTqNx.mjs';
|
|
17
19
|
|
|
18
20
|
const matchesWorkspaceGlobs = (path, globs) => globs.some((glob) => {
|
|
19
21
|
const pattern = glob.replace(/\/+$/, "").split("/").map((part) => part === "**" ? ".*" : part.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*")).join("/");
|
|
@@ -77,7 +79,7 @@ const planModuleMove = async (options) => {
|
|
|
77
79
|
};
|
|
78
80
|
const moduleMove = defineCommand({
|
|
79
81
|
meta: {
|
|
80
|
-
name: "
|
|
82
|
+
name: "move",
|
|
81
83
|
description: "Move a local module or a package folder to another directory, fixing relative paths"
|
|
82
84
|
},
|
|
83
85
|
args: defineCommandArgs({
|
|
@@ -106,7 +108,7 @@ const moduleMove = defineCommand({
|
|
|
106
108
|
}
|
|
107
109
|
}),
|
|
108
110
|
async run({ args }) {
|
|
109
|
-
const logger = consola.withTag("module
|
|
111
|
+
const logger = consola.withTag("module move");
|
|
110
112
|
const result = await planModuleMove({
|
|
111
113
|
cwd: resolveArg(process.cwd(), args.cwd),
|
|
112
114
|
module: args.module,
|
|
@@ -120,7 +122,7 @@ const moduleMove = defineCommand({
|
|
|
120
122
|
if (!args.dryRun) await applyPlan(result.plan);
|
|
121
123
|
const rel = (path) => toPosix(relative(result.root, path));
|
|
122
124
|
logger.success(`${args.dryRun ? "Would move" : "Moved"} ${rel(result.module.path)} \u2192 ${rel(result.to)}`);
|
|
123
|
-
printPlan(result.plan, "module
|
|
125
|
+
printPlan(result.plan, "module move", {
|
|
124
126
|
dryRun: args.dryRun,
|
|
125
127
|
next: result.module.kind === "package" ? ["`pnpm install` so pnpm links the package from its new folder"] : ["Restart `nuxi dev` (or run `nuxi prepare`) in both apps: Nuxt only scans modules/ on start"]
|
|
126
128
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineCommand } from 'citty';
|
|
2
|
+
|
|
3
|
+
const index = defineCommand({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "module",
|
|
6
|
+
description: "Find, inspect and install Frigear modules, and scaffold or refactor your own"
|
|
7
|
+
},
|
|
8
|
+
subCommands: {
|
|
9
|
+
list: () => import('./list2.mjs').then((module) => module.default),
|
|
10
|
+
info: () => import('./info.mjs').then((module) => module.default),
|
|
11
|
+
add: () => import('./add2.mjs').then((module) => module.default),
|
|
12
|
+
create: () => import('./module-create.mjs').then((module) => module.default),
|
|
13
|
+
folder: () => import('./module-folder.mjs').then((module) => module.default),
|
|
14
|
+
move: () => import('./module-move.mjs').then((module) => module.default)
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export { index as default };
|
|
@@ -3,7 +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 { d as defineCommandArgs, f as findWorkspaceRoot,
|
|
6
|
+
import { d as defineCommandArgs, f as findWorkspaceRoot, w as workspacePackageDirs, b as readPackage, p as packageScope } from '../shared/cli.A6PoFRmM.mjs';
|
|
7
7
|
import { r as resolveArg, a as applyPlan, p as printPlan, t as toPosix, b as planChanges } from '../shared/cli.BLUxtpPi.mjs';
|
|
8
8
|
import 'scule';
|
|
9
9
|
import 'pkg-types';
|
package/dist/chunks/upgrade.mjs
CHANGED
|
@@ -3,9 +3,10 @@ import consola from 'consola';
|
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import { readFile, writeFile, readdir, stat, mkdir, rename } from 'node:fs/promises';
|
|
5
5
|
import { join, basename, relative, dirname, resolve } from 'node:path';
|
|
6
|
-
import { parseModule } from 'magicast';
|
|
6
|
+
import { parseModule, generateCode } from 'magicast';
|
|
7
7
|
import { getDefaultExportOptions } from 'magicast/helpers';
|
|
8
|
-
import { m as isBetween, n as duplicateVersions, s as sharedDuplicates, d as defineCommandArgs, f as findWorkspaceRoot, o as manifestFiles, q as findPins, u as currentVersions, v as compareVersions, x as rewritePins, y as movePatchedDependencies } from '../shared/cli.
|
|
8
|
+
import { m as isBetween, n as duplicateVersions, s as sharedDuplicates, d as defineCommandArgs, f as findWorkspaceRoot, o as manifestFiles, q as findPins, u as currentVersions, v as compareVersions, x as rewritePins, y as movePatchedDependencies } from '../shared/cli.A6PoFRmM.mjs';
|
|
9
|
+
import { p as parseTargets, l as latestVersion } from '../shared/cli.Dh9sTqNx.mjs';
|
|
9
10
|
import { i as installDeps } from '../shared/cli.C-q4Gf2K.mjs';
|
|
10
11
|
|
|
11
12
|
const DOCS = "https://docs.frigear.dev";
|
|
@@ -126,6 +127,61 @@ const accountComponents = {
|
|
|
126
127
|
]
|
|
127
128
|
};
|
|
128
129
|
|
|
130
|
+
const documentPaths = (documents) => items(documents).map((document) => option(document, "path")).filter((path) => typeof path === "string");
|
|
131
|
+
const accountDocuments = {
|
|
132
|
+
id: "account-documents",
|
|
133
|
+
package: "@frigear-nu/account",
|
|
134
|
+
since: "0.7.0",
|
|
135
|
+
title: "The account documents page moved to @frigear-nu/documents",
|
|
136
|
+
docs: `${DOCS}/modules/content/documents`,
|
|
137
|
+
rules: [
|
|
138
|
+
{
|
|
139
|
+
pattern: /(['"`])\/account\/documents\b/g,
|
|
140
|
+
message: "`/account/documents` is gone: link to the documents page of `@frigear-nu/documents` (`/dashboard/documents` by default) instead."
|
|
141
|
+
}
|
|
142
|
+
],
|
|
143
|
+
steps: [
|
|
144
|
+
"Install `@frigear-nu/documents` (`frigear-nu add documents`) and upload the files the account listed through `/admin/documents`, shared with the same people (signed-in users, or a role in place of the old `permission`). Then delete them from `public/`, where anyone with the URL could fetch them.",
|
|
145
|
+
"Remove the permissions the app registered only for account documents (in `authentication.permissions` and the roles' `grant`)."
|
|
146
|
+
],
|
|
147
|
+
async project({ root, files, dryRun }) {
|
|
148
|
+
const applied = [];
|
|
149
|
+
const manual = [];
|
|
150
|
+
for (const file of nuxtConfigs(files)) {
|
|
151
|
+
const at = relative(root, file);
|
|
152
|
+
let mod;
|
|
153
|
+
let options;
|
|
154
|
+
try {
|
|
155
|
+
mod = parseModule(await readFile(file, "utf-8"));
|
|
156
|
+
options = getDefaultExportOptions(mod);
|
|
157
|
+
} catch {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
const settings = option(options, "account.settings");
|
|
161
|
+
if (!settings) continue;
|
|
162
|
+
const pages = option(settings, "pages");
|
|
163
|
+
const removed = [];
|
|
164
|
+
const paths = documentPaths(settings.documents);
|
|
165
|
+
if (settings.documents !== void 0) {
|
|
166
|
+
delete settings.documents;
|
|
167
|
+
removed.push("`account.settings.documents`");
|
|
168
|
+
}
|
|
169
|
+
if (pages?.documents !== void 0) {
|
|
170
|
+
delete pages.documents;
|
|
171
|
+
removed.push("`account.settings.pages.documents`");
|
|
172
|
+
}
|
|
173
|
+
if (!removed.length) continue;
|
|
174
|
+
if (!dryRun) await writeFile(file, `${generateCode(mod).code.trimEnd()}
|
|
175
|
+
`, "utf-8");
|
|
176
|
+
applied.push(`${at}: removed ${removed.join(" and ")}`);
|
|
177
|
+
if (paths.length) {
|
|
178
|
+
manual.push(`${at}: the account listed ${paths.map((path) => `\`${path}\``).join(", ")}. Upload them through \`/admin/documents\` of \`@frigear-nu/documents\`, shared with the same people, then delete them from \`public/\`.`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return { applied, manual };
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
129
185
|
const GUIDE = `${DOCS}/guide/going-further/migrate-access-control`;
|
|
130
186
|
const authPermissions = {
|
|
131
187
|
id: "auth-permissions",
|
|
@@ -358,6 +414,66 @@ const mcpPermission = {
|
|
|
358
414
|
]
|
|
359
415
|
};
|
|
360
416
|
|
|
417
|
+
const PRELOAD_DOCS = `${DOCS}/modules/platform/module-kit/registries-and-menus#preload-providers`;
|
|
418
|
+
const moduleKitPreload = {
|
|
419
|
+
id: "module-kit-preload",
|
|
420
|
+
package: "@frigear-nu/module-kit",
|
|
421
|
+
since: "1.4.0",
|
|
422
|
+
title: "Bootstrap providers are preload providers",
|
|
423
|
+
docs: PRELOAD_DOCS,
|
|
424
|
+
rules: [
|
|
425
|
+
{
|
|
426
|
+
pattern: /\bregisterBootstrapProvider\b/g,
|
|
427
|
+
replace: "registerPreloadProvider",
|
|
428
|
+
message: "`registerBootstrapProvider` is `registerPreloadProvider`: rename its `scope:` option to `area:`. The route no longer authenticates, so check the caller in the handler (`authorize(event, ...)`) unless every visitor may see the data."
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
pattern: /\bgetBootstrapProviders\b/g,
|
|
432
|
+
replace: "getPreloadProviders",
|
|
433
|
+
message: "`getBootstrapProviders` is `getPreloadProviders` (providers carry `area`, not `scope`)."
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
pattern: /\bdefineBootstrapRegistry\b/g,
|
|
437
|
+
message: "`defineBootstrapRegistry` is gone: the module that owns an area calls `servePreloadArea(nuxt, { area })`, which mounts `GET /api/<area>/preload`."
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
pattern: /#bootstrap\/providers\b/g,
|
|
441
|
+
replace: "#preload/providers",
|
|
442
|
+
message: "`#bootstrap/providers` is `#preload/providers`."
|
|
443
|
+
}
|
|
444
|
+
]
|
|
445
|
+
};
|
|
446
|
+
const uiPreload = {
|
|
447
|
+
id: "ui-preload",
|
|
448
|
+
package: "@frigear-nu/ui",
|
|
449
|
+
since: "0.3.0",
|
|
450
|
+
title: "loadBootstrap is loadPreload",
|
|
451
|
+
docs: `${DOCS}/modules/interface/ui/composables#one-request-for-an-area-loadpreload`,
|
|
452
|
+
rules: [
|
|
453
|
+
{
|
|
454
|
+
pattern: /\bloadBootstrap\b/g,
|
|
455
|
+
replace: "loadPreload",
|
|
456
|
+
message: "`loadBootstrap(scope)` is `loadPreload(area)`. It fetches `GET /api/<area>/preload` (pass `url` when the area is served elsewhere), so the area needs `servePreloadArea`."
|
|
457
|
+
},
|
|
458
|
+
{ pattern: /\bresetBootstrap\b/g, replace: "resetPreload", message: "`resetBootstrap` is `resetPreload`." },
|
|
459
|
+
{ pattern: /\buseBootstrapState\b/g, replace: "usePreloadState", message: "`useBootstrapState` is `usePreloadState`." },
|
|
460
|
+
{ pattern: /\bBOOTSTRAP_TTL_MS\b/g, replace: "PRELOAD_TTL_MS", message: "`BOOTSTRAP_TTL_MS` is `PRELOAD_TTL_MS`." }
|
|
461
|
+
]
|
|
462
|
+
};
|
|
463
|
+
const authBootstrapRoute = {
|
|
464
|
+
id: "auth-bootstrap-route",
|
|
465
|
+
package: "@frigear-nu/auth",
|
|
466
|
+
since: "0.7.0",
|
|
467
|
+
title: "/api/auth/bootstrap moved to the area owners",
|
|
468
|
+
docs: PRELOAD_DOCS,
|
|
469
|
+
rules: [
|
|
470
|
+
{
|
|
471
|
+
pattern: /\/api\/auth\/bootstrap\b|\bauthApi\.bootstrap\b/g,
|
|
472
|
+
message: "Auth no longer serves `/api/auth/bootstrap?scope=<scope>`: each area serves `GET /api/<area>/preload` (the account preload is `/api/account/preload`). Call `loadPreload(area)` instead of fetching it, or fetch the area's route."
|
|
473
|
+
}
|
|
474
|
+
]
|
|
475
|
+
};
|
|
476
|
+
|
|
361
477
|
const UPGRADING = `${DOCS}/get-started/upgrading`;
|
|
362
478
|
const authRoutes = {
|
|
363
479
|
id: "auth-routes",
|
|
@@ -458,6 +574,45 @@ const oauthServerApplicationsPage = {
|
|
|
458
574
|
return { manual };
|
|
459
575
|
}
|
|
460
576
|
};
|
|
577
|
+
const teamsProjects = {
|
|
578
|
+
id: "teams-projects",
|
|
579
|
+
package: "@frigear-nu/teams",
|
|
580
|
+
since: "0.2.0",
|
|
581
|
+
title: "Projects are their own records, not a team kind",
|
|
582
|
+
docs: `${DOCS}/modules/organisation/teams#projects`,
|
|
583
|
+
schema: true,
|
|
584
|
+
rules: [
|
|
585
|
+
{
|
|
586
|
+
pattern: /\bPROJECT_TEAM_KIND\b/g,
|
|
587
|
+
message: "Removed: projects are no team kind any more. Use the project routes (`teamsApi.admin.projects`, `teamsApi.publicProjects`) instead of teams of kind `project`."
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
pattern: /\bkind:\s*['"]project['"]/g,
|
|
591
|
+
message: "The shipped `project` ladder is gone: a seeded or created team of kind `project` fails (no ladder). Move seeds to `teams.seed.projects` (no `kind`), or define a `project` ladder of your own."
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
pattern: /\/api\/admin\/teams\/[^'"`\s]*\/contributions\b|\bteamsApi\.admin\.contributions?\b/g,
|
|
595
|
+
message: "The `contributions` routes are removed: teams are linked to a project with `/api/admin/projects/:id/teams` (`teamsApi.admin.projectTeams(id)`), and a team's projects are read with `teamsApi.admin.teamProjects(id)`."
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
pattern: /\b(?:useTeamContributionActions|TeamContributionSlideover)\b/g,
|
|
599
|
+
message: "Removed: use `useProjectTeamActions(project)` (and `ProjectTeamSlideover`) on the project page."
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
pattern: /\.(?:contributors|workingOn)\b/g,
|
|
603
|
+
message: "The public team DTO has `projects` (the public projects it works on) instead of `contributors` and `workingOn`. Check this is the teams DTO.",
|
|
604
|
+
files: /\.(?:vue|ts)$/
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
pattern: /\bmultipleSections\b/g,
|
|
608
|
+
message: '`public.teams.multipleSections` is removed: the admin always says "Teams"; projects have their own admin page (`settings.pages.adminProjects`).'
|
|
609
|
+
}
|
|
610
|
+
],
|
|
611
|
+
steps: [
|
|
612
|
+
"Turn on the project admin pages with `teams.settings.pages.adminProjects` and `adminProject` (`true`), next to `admin` and `adminTeam`.",
|
|
613
|
+
"Generate the app's migration and edit it to copy teams of kind `project` into `projects` (their members into `project_members`, their links into `project_teams`) before `team_contributions` is dropped, then delete those teams and the `project` ladder row. Uploaded images are not moved: upload them again."
|
|
614
|
+
]
|
|
615
|
+
};
|
|
461
616
|
|
|
462
617
|
const SERVER_AUTH = ["@frigear-nu/auth", "@frigear-nu/users", "@frigear-nu/oauth-server"];
|
|
463
618
|
const hasServerSessions = async (config, options) => {
|
|
@@ -523,30 +678,14 @@ const migrations = [
|
|
|
523
678
|
accountPermission,
|
|
524
679
|
usersPermissions,
|
|
525
680
|
eventsTicketsPage,
|
|
526
|
-
oauthServerApplicationsPage
|
|
681
|
+
oauthServerApplicationsPage,
|
|
682
|
+
moduleKitPreload,
|
|
683
|
+
uiPreload,
|
|
684
|
+
authBootstrapRoute,
|
|
685
|
+
teamsProjects,
|
|
686
|
+
accountDocuments
|
|
527
687
|
];
|
|
528
688
|
|
|
529
|
-
const REGISTRY = (process.env.npm_config_registry || "https://registry.npmjs.org").replace(/\/+$/, "");
|
|
530
|
-
const latestVersion = async (name) => {
|
|
531
|
-
const response = await fetch(`${REGISTRY}/${name.replace("/", "%2f")}`, {
|
|
532
|
-
headers: { accept: "application/vnd.npm.install-v1+json" }
|
|
533
|
-
});
|
|
534
|
-
if (response.status === 404) return void 0;
|
|
535
|
-
if (!response.ok) throw new Error(`npm registry answered ${response.status} for ${name}`);
|
|
536
|
-
const body = await response.json();
|
|
537
|
-
return body["dist-tags"]?.latest;
|
|
538
|
-
};
|
|
539
|
-
const parseTargets = (value) => {
|
|
540
|
-
const targets = {};
|
|
541
|
-
for (const spec of (value ?? "").split(/[\s,]+/).filter(Boolean)) {
|
|
542
|
-
const at = spec.lastIndexOf("@");
|
|
543
|
-
if (at <= 0) throw new Error(`Expected <package>@<version>, got "${spec}"`);
|
|
544
|
-
const name = spec.slice(0, at);
|
|
545
|
-
targets[name.includes("/") ? name : `@frigear-nu/${name}`] = spec.slice(at + 1);
|
|
546
|
-
}
|
|
547
|
-
return targets;
|
|
548
|
-
};
|
|
549
|
-
|
|
550
689
|
const code = (text) => `\`${text.replace(/`/g, "'")}\``;
|
|
551
690
|
const renderReport = ({ root, from, to, bumps, results, dryRun }) => {
|
|
552
691
|
const at = (hit) => `${relative(root, hit.file)}:${hit.line}`;
|
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as citty from 'citty';
|
|
2
|
+
import { CommandDef, ArgsDef } from 'citty';
|
|
2
3
|
import { ConsolaInstance } from 'consola';
|
|
3
4
|
import { PackageJson } from 'pkg-types';
|
|
4
5
|
|
|
5
|
-
declare const mainCmd:
|
|
6
|
+
declare const mainCmd: CommandDef<ArgsDef>;
|
|
6
7
|
declare function main(): Promise<void>;
|
|
7
8
|
|
|
8
9
|
declare const PLATFORMS: readonly ["web", "mobile", "desktop"];
|
|
@@ -463,5 +464,61 @@ declare const prepareEnv: (options: PrepareEnvOptions) => Promise<PrepareEnvResu
|
|
|
463
464
|
/** One line per file, as the command prints it. */
|
|
464
465
|
declare const describeEnvResult: (result: PrepareEnvResult) => string;
|
|
465
466
|
|
|
466
|
-
|
|
467
|
-
|
|
467
|
+
/** The npm keyword a package carries to show up in `module list`, first-party or third-party. */
|
|
468
|
+
declare const MODULE_KEYWORD = "frigear-module";
|
|
469
|
+
/** `forms` → `@frigear-nu/forms`; scoped names and paths are kept. */
|
|
470
|
+
declare const resolveModuleName: (name: string) => string;
|
|
471
|
+
interface ModuleSummary {
|
|
472
|
+
name: string;
|
|
473
|
+
version: string;
|
|
474
|
+
description?: string;
|
|
475
|
+
firstParty: boolean;
|
|
476
|
+
homepage?: string;
|
|
477
|
+
repository?: string;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Frigear modules on the npm registry: the `@frigear-nu` packages that are modules (not deprecated, not in
|
|
481
|
+
* {@link NOT_MODULES}), plus third-party packages with the `frigear-module` keyword. First-party first, then by name.
|
|
482
|
+
* `text` filters on name and description.
|
|
483
|
+
*/
|
|
484
|
+
declare const searchModules: (text?: string) => Promise<ModuleSummary[]>;
|
|
485
|
+
interface ModuleManifest {
|
|
486
|
+
name: string;
|
|
487
|
+
version?: string;
|
|
488
|
+
description?: string;
|
|
489
|
+
homepage?: string;
|
|
490
|
+
license?: string;
|
|
491
|
+
repository?: string | {
|
|
492
|
+
url?: string;
|
|
493
|
+
directory?: string;
|
|
494
|
+
};
|
|
495
|
+
exports?: unknown;
|
|
496
|
+
keywords?: string[];
|
|
497
|
+
dependencies?: Record<string, string>;
|
|
498
|
+
peerDependencies?: Record<string, string>;
|
|
499
|
+
peerDependenciesMeta?: Record<string, {
|
|
500
|
+
optional?: boolean;
|
|
501
|
+
}>;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* What goes into `modules` in `nuxt.config` for a package. Like Nuxt modules in the wild, the module can live at the
|
|
505
|
+
* package root or at a subpath: `./module`, then `./nuxt`, then the package itself.
|
|
506
|
+
*/
|
|
507
|
+
declare const moduleEntry: (manifest: Pick<ModuleManifest, "name" | "exports">) => string;
|
|
508
|
+
interface ModuleInfo extends ModuleManifest {
|
|
509
|
+
version: string;
|
|
510
|
+
/** The `modules` entry for `nuxt.config`. */
|
|
511
|
+
entry: string;
|
|
512
|
+
deprecated?: string;
|
|
513
|
+
repositoryUrl?: string;
|
|
514
|
+
}
|
|
515
|
+
/** The latest published version of `name`, or `undefined` when the registry does not have it. */
|
|
516
|
+
declare const fetchModuleInfo: (name: string) => Promise<ModuleInfo | undefined>;
|
|
517
|
+
/**
|
|
518
|
+
* Looks up a module by short or full name: `users` is `@frigear-nu/users`, and when that is not published, the
|
|
519
|
+
* unscoped package `users` (a third-party module).
|
|
520
|
+
*/
|
|
521
|
+
declare const findModule: (input: string) => Promise<ModuleInfo | undefined>;
|
|
522
|
+
|
|
523
|
+
export { APP_TEMPLATES, BUILTIN_PLATFORMS, BUILTIN_SECRETS, DEFAULT_ENV_DIRS, MODULE_KEYWORD, PLATFORMS, PlatformError, STARTERS, addPlatform, main as default, definePlatform, describeEnvResult, detectAppPlatform, fetchModuleInfo, fillPlaceholders, findModule, findTarget, generateSecret, _default as initCmd, initPlatform, isTemplateSource, listWorkspaceApps, mainCmd, mergeRootScripts, migrations, moduleEntry, platformRegistry, platformScripts, prepareEnv, resolveAppScope, resolveAppsDir, resolveEnvConfig, resolveModuleName, resolvePlatform, resolvePlatformApp, resolveStarter, resolveTemplateSource, searchModules, targetCommand, upgradeWorkspace };
|
|
524
|
+
export type { AddPlatformOptions, AddPlatformResult, AppTemplate, AppsDir, EnvConfig, InitPlatformOptions, InitPlatformResult, Migration, ModuleInfo, ModuleManifest, ModuleSummary, NextStepsContext, Platform, PlatformDefinition, PlatformErrorCode, PlatformRegistry, PlatformTarget, PrepareEnvOptions, PrepareEnvResult, ResolvePlatformAppOptions, Rule, SecretGenerator, Starter, UpgradeOptions, WorkspaceApp };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as citty from 'citty';
|
|
2
|
+
import { CommandDef, ArgsDef } from 'citty';
|
|
2
3
|
import { ConsolaInstance } from 'consola';
|
|
3
4
|
import { PackageJson } from 'pkg-types';
|
|
4
5
|
|
|
5
|
-
declare const mainCmd:
|
|
6
|
+
declare const mainCmd: CommandDef<ArgsDef>;
|
|
6
7
|
declare function main(): Promise<void>;
|
|
7
8
|
|
|
8
9
|
declare const PLATFORMS: readonly ["web", "mobile", "desktop"];
|
|
@@ -463,5 +464,61 @@ declare const prepareEnv: (options: PrepareEnvOptions) => Promise<PrepareEnvResu
|
|
|
463
464
|
/** One line per file, as the command prints it. */
|
|
464
465
|
declare const describeEnvResult: (result: PrepareEnvResult) => string;
|
|
465
466
|
|
|
466
|
-
|
|
467
|
-
|
|
467
|
+
/** The npm keyword a package carries to show up in `module list`, first-party or third-party. */
|
|
468
|
+
declare const MODULE_KEYWORD = "frigear-module";
|
|
469
|
+
/** `forms` → `@frigear-nu/forms`; scoped names and paths are kept. */
|
|
470
|
+
declare const resolveModuleName: (name: string) => string;
|
|
471
|
+
interface ModuleSummary {
|
|
472
|
+
name: string;
|
|
473
|
+
version: string;
|
|
474
|
+
description?: string;
|
|
475
|
+
firstParty: boolean;
|
|
476
|
+
homepage?: string;
|
|
477
|
+
repository?: string;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Frigear modules on the npm registry: the `@frigear-nu` packages that are modules (not deprecated, not in
|
|
481
|
+
* {@link NOT_MODULES}), plus third-party packages with the `frigear-module` keyword. First-party first, then by name.
|
|
482
|
+
* `text` filters on name and description.
|
|
483
|
+
*/
|
|
484
|
+
declare const searchModules: (text?: string) => Promise<ModuleSummary[]>;
|
|
485
|
+
interface ModuleManifest {
|
|
486
|
+
name: string;
|
|
487
|
+
version?: string;
|
|
488
|
+
description?: string;
|
|
489
|
+
homepage?: string;
|
|
490
|
+
license?: string;
|
|
491
|
+
repository?: string | {
|
|
492
|
+
url?: string;
|
|
493
|
+
directory?: string;
|
|
494
|
+
};
|
|
495
|
+
exports?: unknown;
|
|
496
|
+
keywords?: string[];
|
|
497
|
+
dependencies?: Record<string, string>;
|
|
498
|
+
peerDependencies?: Record<string, string>;
|
|
499
|
+
peerDependenciesMeta?: Record<string, {
|
|
500
|
+
optional?: boolean;
|
|
501
|
+
}>;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* What goes into `modules` in `nuxt.config` for a package. Like Nuxt modules in the wild, the module can live at the
|
|
505
|
+
* package root or at a subpath: `./module`, then `./nuxt`, then the package itself.
|
|
506
|
+
*/
|
|
507
|
+
declare const moduleEntry: (manifest: Pick<ModuleManifest, "name" | "exports">) => string;
|
|
508
|
+
interface ModuleInfo extends ModuleManifest {
|
|
509
|
+
version: string;
|
|
510
|
+
/** The `modules` entry for `nuxt.config`. */
|
|
511
|
+
entry: string;
|
|
512
|
+
deprecated?: string;
|
|
513
|
+
repositoryUrl?: string;
|
|
514
|
+
}
|
|
515
|
+
/** The latest published version of `name`, or `undefined` when the registry does not have it. */
|
|
516
|
+
declare const fetchModuleInfo: (name: string) => Promise<ModuleInfo | undefined>;
|
|
517
|
+
/**
|
|
518
|
+
* Looks up a module by short or full name: `users` is `@frigear-nu/users`, and when that is not published, the
|
|
519
|
+
* unscoped package `users` (a third-party module).
|
|
520
|
+
*/
|
|
521
|
+
declare const findModule: (input: string) => Promise<ModuleInfo | undefined>;
|
|
522
|
+
|
|
523
|
+
export { APP_TEMPLATES, BUILTIN_PLATFORMS, BUILTIN_SECRETS, DEFAULT_ENV_DIRS, MODULE_KEYWORD, PLATFORMS, PlatformError, STARTERS, addPlatform, main as default, definePlatform, describeEnvResult, detectAppPlatform, fetchModuleInfo, fillPlaceholders, findModule, findTarget, generateSecret, _default as initCmd, initPlatform, isTemplateSource, listWorkspaceApps, mainCmd, mergeRootScripts, migrations, moduleEntry, platformRegistry, platformScripts, prepareEnv, resolveAppScope, resolveAppsDir, resolveEnvConfig, resolveModuleName, resolvePlatform, resolvePlatformApp, resolveStarter, resolveTemplateSource, searchModules, targetCommand, upgradeWorkspace };
|
|
524
|
+
export type { AddPlatformOptions, AddPlatformResult, AppTemplate, AppsDir, EnvConfig, InitPlatformOptions, InitPlatformResult, Migration, ModuleInfo, ModuleManifest, ModuleSummary, NextStepsContext, Platform, PlatformDefinition, PlatformErrorCode, PlatformRegistry, PlatformTarget, PrepareEnvOptions, PrepareEnvResult, ResolvePlatformAppOptions, Rule, SecretGenerator, Starter, UpgradeOptions, WorkspaceApp };
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export { m as default, a as mainCmd } from './shared/cli.
|
|
1
|
+
export { m as default, a as mainCmd } from './shared/cli.IEy-SSS4.mjs';
|
|
2
2
|
export { PLATFORMS, STARTERS, default as initCmd, resolveStarter } from './chunks/init.mjs';
|
|
3
3
|
export { m as migrations, u as upgradeWorkspace } from './chunks/upgrade.mjs';
|
|
4
|
-
export { a as addPlatform, f as fillPlaceholders, m as mergeRootScripts, p as platformScripts, r as resolveAppScope, b as resolvePlatform, c as resolveTemplateSource } from './shared/cli.
|
|
4
|
+
export { a as addPlatform, f as fillPlaceholders, m as mergeRootScripts, p as platformScripts, r as resolveAppScope, b as resolvePlatform, c as resolveTemplateSource } from './shared/cli._jTVAy9s.mjs';
|
|
5
5
|
export { A as APP_TEMPLATES, B as BUILTIN_PLATFORMS, d as definePlatform, f as findTarget, i as isTemplateSource, p as platformRegistry } from './shared/cli.DnhGPz3G.mjs';
|
|
6
|
-
export { P as PlatformError, r as resolveAppsDir } from './shared/cli.
|
|
7
|
-
export { d as detectAppPlatform, i as initPlatform, l as listWorkspaceApps, r as resolvePlatformApp, t as targetCommand } from './shared/cli.
|
|
6
|
+
export { P as PlatformError, r as resolveAppsDir } from './shared/cli.A6PoFRmM.mjs';
|
|
7
|
+
export { d as detectAppPlatform, i as initPlatform, l as listWorkspaceApps, r as resolvePlatformApp, t as targetCommand } from './shared/cli.BCgeZaNi.mjs';
|
|
8
8
|
export { B as BUILTIN_SECRETS, D as DEFAULT_ENV_DIRS, d as describeEnvResult, g as generateSecret, p as prepareEnv, r as resolveEnvConfig } from './shared/cli.s0Wk6nL9.mjs';
|
|
9
|
+
export { M as MODULE_KEYWORD, f as fetchModuleInfo, a as findModule, m as moduleEntry, r as resolveModuleName, s as searchModules } from './shared/cli.DLJLsgDV.mjs';
|
|
9
10
|
import 'citty';
|
|
10
11
|
import 'consola';
|
|
11
12
|
import 'node:path';
|
|
@@ -19,6 +20,7 @@ import 'node:os';
|
|
|
19
20
|
import 'node:fs';
|
|
20
21
|
import 'magicast';
|
|
21
22
|
import 'magicast/helpers';
|
|
23
|
+
import './shared/cli.Dh9sTqNx.mjs';
|
|
22
24
|
import 'pkg-types';
|
|
23
25
|
import './shared/cli.BLUxtpPi.mjs';
|
|
24
26
|
import 'scule';
|
|
@@ -281,4 +281,4 @@ const resolveAppsDir = async ({ cwd, root, appsDir }) => {
|
|
|
281
281
|
return { dir, covered: covered(dir) };
|
|
282
282
|
};
|
|
283
283
|
|
|
284
|
-
export { PlatformError as P, renamePackage as a, readPackage as b, templateArgs as c, defineCommandArgs as d,
|
|
284
|
+
export { PlatformError as P, renamePackage as a, readPackage as b, templateArgs as c, defineCommandArgs as d, workspaceGlobs as e, findWorkspaceRoot as f, workspacePackageNames as g, hasPackage as h, isEmptyDir as i, freePackageName as j, isInside as k, listDirs as l, isBetween as m, duplicateVersions as n, manifestFiles as o, packageScope as p, findPins as q, resolveAppsDir as r, sharedDuplicates as s, toPackageName as t, currentVersions as u, compareVersions as v, workspacePackageDirs as w, rewritePins as x, movePatchedDependencies as y };
|
|
@@ -3,7 +3,7 @@ import { existsSync } from 'node:fs';
|
|
|
3
3
|
import { relative, join, resolve } from 'node:path';
|
|
4
4
|
import { r as runPackageScript, e as execBin } from './cli.C-q4Gf2K.mjs';
|
|
5
5
|
import { t as toPosix } from './cli.BLUxtpPi.mjs';
|
|
6
|
-
import { l as listDirs, b as readPackage, f as findWorkspaceRoot, P as PlatformError, r as resolveAppsDir, h as hasPackage, k as isInside } from './cli.
|
|
6
|
+
import { l as listDirs, b as readPackage, f as findWorkspaceRoot, P as PlatformError, r as resolveAppsDir, h as hasPackage, k as isInside } from './cli.A6PoFRmM.mjs';
|
|
7
7
|
import { p as platformRegistry, f as findTarget } from './cli.DnhGPz3G.mjs';
|
|
8
8
|
|
|
9
9
|
const detectAppPlatform = (registry, pkg) => {
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { R as REGISTRY } from './cli.Dh9sTqNx.mjs';
|
|
2
|
+
|
|
3
|
+
const MODULE_KEYWORD = "frigear-module";
|
|
4
|
+
const FIRST_PARTY_SCOPE = "@frigear-nu";
|
|
5
|
+
const NOT_MODULES = /* @__PURE__ */ new Set([
|
|
6
|
+
"@frigear-nu/cli",
|
|
7
|
+
"@frigear-nu/eslint-config",
|
|
8
|
+
"@frigear-nu/module-kit",
|
|
9
|
+
"@frigear-nu/base",
|
|
10
|
+
"create-frigear-app"
|
|
11
|
+
]);
|
|
12
|
+
const resolveModuleName = (name) => name.includes("/") ? name : `${FIRST_PARTY_SCOPE}/${name}`;
|
|
13
|
+
const shortModuleName = (name) => name.startsWith(`${FIRST_PARTY_SCOPE}/`) ? name.slice(FIRST_PARTY_SCOPE.length + 1) : name;
|
|
14
|
+
const isFirstParty = (name) => name.startsWith(`${FIRST_PARTY_SCOPE}/`);
|
|
15
|
+
const isModuleName = (name, known = []) => isFirstParty(name) && !NOT_MODULES.has(name) || new Set(known).has(name);
|
|
16
|
+
const repositoryUrl = (repository) => {
|
|
17
|
+
const url = typeof repository === "string" ? repository : repository?.url;
|
|
18
|
+
return url?.replace(/^git\+/, "").replace(/\.git$/, "");
|
|
19
|
+
};
|
|
20
|
+
const getJson = async (path) => {
|
|
21
|
+
const response = await fetch(`${REGISTRY}${path}`);
|
|
22
|
+
if (response.status === 404) return void 0;
|
|
23
|
+
if (!response.ok) throw new Error(`npm registry answered ${response.status} for ${path}`);
|
|
24
|
+
return await response.json();
|
|
25
|
+
};
|
|
26
|
+
const search = async (text) => ((await getJson(`/-/v1/search?size=250&text=${encodeURIComponent(text)}`))?.objects ?? []).map((object) => object.package);
|
|
27
|
+
const latestManifest = (name) => getJson(`/${name.replace("/", "%2f")}/latest`);
|
|
28
|
+
const firstPartyNames = async () => {
|
|
29
|
+
const listing = await getJson(`/-/org/${FIRST_PARTY_SCOPE.slice(1)}/package`).catch(() => void 0);
|
|
30
|
+
const names = listing ? Object.keys(listing) : (await search(`scope:${FIRST_PARTY_SCOPE}`)).map((pkg) => pkg.name);
|
|
31
|
+
return names.filter((name) => isFirstParty(name) && !NOT_MODULES.has(name));
|
|
32
|
+
};
|
|
33
|
+
const summary = (manifest) => ({
|
|
34
|
+
name: manifest.name,
|
|
35
|
+
version: manifest.version,
|
|
36
|
+
description: manifest.description,
|
|
37
|
+
firstParty: isFirstParty(manifest.name),
|
|
38
|
+
homepage: manifest.homepage,
|
|
39
|
+
repository: repositoryUrl(manifest.repository)
|
|
40
|
+
});
|
|
41
|
+
const searchModules = async (text) => {
|
|
42
|
+
const [names, byKeyword] = await Promise.all([firstPartyNames(), search(`keywords:${MODULE_KEYWORD}`)]);
|
|
43
|
+
const firstParty = await Promise.all(names.map((name) => latestManifest(name).catch(() => void 0)));
|
|
44
|
+
const modules = /* @__PURE__ */ new Map();
|
|
45
|
+
for (const manifest of firstParty) {
|
|
46
|
+
if (manifest?.version && !manifest.deprecated) modules.set(manifest.name, summary({ ...manifest, version: manifest.version }));
|
|
47
|
+
}
|
|
48
|
+
for (const pkg of byKeyword) {
|
|
49
|
+
if (isFirstParty(pkg.name) || modules.has(pkg.name) || !pkg.keywords?.includes(MODULE_KEYWORD)) continue;
|
|
50
|
+
modules.set(pkg.name, {
|
|
51
|
+
name: pkg.name,
|
|
52
|
+
version: pkg.version,
|
|
53
|
+
description: pkg.description,
|
|
54
|
+
firstParty: false,
|
|
55
|
+
homepage: pkg.links?.homepage,
|
|
56
|
+
repository: pkg.links?.repository
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const needle = text?.trim().toLowerCase();
|
|
60
|
+
return [...modules.values()].filter((mod) => !needle || `${mod.name} ${mod.description ?? ""}`.toLowerCase().includes(needle)).sort((a, b) => Number(b.firstParty) - Number(a.firstParty) || a.name.localeCompare(b.name));
|
|
61
|
+
};
|
|
62
|
+
const moduleEntry = (manifest) => {
|
|
63
|
+
const exports = manifest.exports;
|
|
64
|
+
if (exports && typeof exports === "object" && !Array.isArray(exports)) {
|
|
65
|
+
for (const subpath of ["module", "nuxt"]) {
|
|
66
|
+
if (`./${subpath}` in exports) return `${manifest.name}/${subpath}`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return manifest.name;
|
|
70
|
+
};
|
|
71
|
+
const fetchModuleInfo = async (name) => {
|
|
72
|
+
const manifest = await latestManifest(name);
|
|
73
|
+
if (!manifest?.version) return void 0;
|
|
74
|
+
return {
|
|
75
|
+
...manifest,
|
|
76
|
+
name: manifest.name,
|
|
77
|
+
version: manifest.version,
|
|
78
|
+
entry: moduleEntry(manifest),
|
|
79
|
+
repositoryUrl: repositoryUrl(manifest.repository)
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
const findModule = async (input) => {
|
|
83
|
+
const name = resolveModuleName(input);
|
|
84
|
+
const info = await fetchModuleInfo(name);
|
|
85
|
+
if (info || input.includes("/")) return info;
|
|
86
|
+
return fetchModuleInfo(input);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { FIRST_PARTY_SCOPE as F, MODULE_KEYWORD as M, findModule as a, shortModuleName as b, isFirstParty as c, fetchModuleInfo as f, isModuleName as i, moduleEntry as m, resolveModuleName as r, searchModules as s };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const REGISTRY = (process.env.npm_config_registry || "https://registry.npmjs.org").replace(/\/+$/, "");
|
|
2
|
+
const latestVersion = async (name) => {
|
|
3
|
+
const response = await fetch(`${REGISTRY}/${name.replace("/", "%2f")}`, {
|
|
4
|
+
headers: { accept: "application/vnd.npm.install-v1+json" }
|
|
5
|
+
});
|
|
6
|
+
if (response.status === 404) return void 0;
|
|
7
|
+
if (!response.ok) throw new Error(`npm registry answered ${response.status} for ${name}`);
|
|
8
|
+
const body = await response.json();
|
|
9
|
+
return body["dist-tags"]?.latest;
|
|
10
|
+
};
|
|
11
|
+
const parseTargets = (value) => {
|
|
12
|
+
const targets = {};
|
|
13
|
+
for (const spec of (value ?? "").split(/[\s,]+/).filter(Boolean)) {
|
|
14
|
+
const at = spec.lastIndexOf("@");
|
|
15
|
+
if (at <= 0) throw new Error(`Expected <package>@<version>, got "${spec}"`);
|
|
16
|
+
const name = spec.slice(0, at);
|
|
17
|
+
targets[name.includes("/") ? name : `@frigear-nu/${name}`] = spec.slice(at + 1);
|
|
18
|
+
}
|
|
19
|
+
return targets;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { REGISTRY as R, latestVersion as l, parseTargets as p };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineCommand, runMain } from 'citty';
|
|
2
|
+
import consola from 'consola';
|
|
3
|
+
|
|
4
|
+
const version = "0.3.0";
|
|
5
|
+
const pkg = {
|
|
6
|
+
version: version};
|
|
7
|
+
|
|
8
|
+
const deprecatedAlias = (alias, replacement, load) => async () => {
|
|
9
|
+
const command = await load();
|
|
10
|
+
const meta = typeof command.meta === "function" ? await command.meta() : await command.meta;
|
|
11
|
+
return {
|
|
12
|
+
...command,
|
|
13
|
+
meta: { ...meta, name: alias, hidden: true, description: `Deprecated: use \`${replacement}\`` },
|
|
14
|
+
run: async (context) => {
|
|
15
|
+
consola.warn(`\`${alias}\` is deprecated, use \`${replacement}\``);
|
|
16
|
+
return command.run?.(context);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const mainCmd = defineCommand({
|
|
21
|
+
meta: {
|
|
22
|
+
name: "frigear-nu",
|
|
23
|
+
version: pkg.version,
|
|
24
|
+
description: "Scaffold Frigear projects, apps and modules, and upgrade them"
|
|
25
|
+
},
|
|
26
|
+
subCommands: {
|
|
27
|
+
"init": () => import('../chunks/init.mjs').then((module) => module.default),
|
|
28
|
+
"platform": () => import('../chunks/platform.mjs').then((module) => module.default),
|
|
29
|
+
"module": () => import('../chunks/module.mjs').then((module) => module.default),
|
|
30
|
+
"add": () => import('../chunks/add2.mjs').then((module) => module.default),
|
|
31
|
+
"app:create": () => import('../chunks/app-create.mjs').then((module) => module.default),
|
|
32
|
+
"package:rename": () => import('../chunks/package-rename.mjs').then((module) => module.default),
|
|
33
|
+
"upgrade": () => import('../chunks/upgrade.mjs').then(function (n) { return n.a; }).then((module) => module.default),
|
|
34
|
+
"prepare": () => import('../chunks/prepare.mjs').then((module) => module.default),
|
|
35
|
+
"module:create": deprecatedAlias("module:create", "module create", () => import('../chunks/module-create.mjs').then((module) => module.default)),
|
|
36
|
+
"module:folder": deprecatedAlias("module:folder", "module folder", () => import('../chunks/module-folder.mjs').then((module) => module.default)),
|
|
37
|
+
"module:move": deprecatedAlias("module:move", "module move", () => import('../chunks/module-move.mjs').then((module) => module.default))
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
async function main() {
|
|
41
|
+
await runMain(mainCmd);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { mainCmd as a, main as m };
|
|
@@ -4,7 +4,7 @@ import { readPackageJSON, writePackageJSON } from 'pkg-types';
|
|
|
4
4
|
import { i as installDeps, r as runPackageScript } from './cli.C-q4Gf2K.mjs';
|
|
5
5
|
import { t as toPosix } from './cli.BLUxtpPi.mjs';
|
|
6
6
|
import { d as downloadTemplateToDir } from './cli.B9jOPxYC.mjs';
|
|
7
|
-
import { f as findWorkspaceRoot, P as PlatformError, b as readPackage, r as resolveAppsDir, t as toPackageName, h as hasPackage, g as workspacePackageNames, j as freePackageName, l as listDirs, p as packageScope } from './cli.
|
|
7
|
+
import { f as findWorkspaceRoot, P as PlatformError, b as readPackage, r as resolveAppsDir, t as toPackageName, h as hasPackage, g as workspacePackageNames, j as freePackageName, l as listDirs, p as packageScope } from './cli.A6PoFRmM.mjs';
|
|
8
8
|
import { p as platformRegistry, i as isTemplateSource } from './cli.DnhGPz3G.mjs';
|
|
9
9
|
|
|
10
10
|
const resolveAppScope = async (root, appsDir = join(root, "apps")) => {
|
package/package.json
CHANGED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { defineCommand, runMain } from 'citty';
|
|
2
|
-
|
|
3
|
-
const version = "0.2.8";
|
|
4
|
-
const pkg = {
|
|
5
|
-
version: version};
|
|
6
|
-
|
|
7
|
-
const mainCmd = defineCommand({
|
|
8
|
-
meta: {
|
|
9
|
-
name: "frigear-nu",
|
|
10
|
-
version: pkg.version,
|
|
11
|
-
description: "Scaffold Frigear projects, apps and modules, and upgrade them"
|
|
12
|
-
},
|
|
13
|
-
subCommands: {
|
|
14
|
-
"init": () => import('../chunks/init.mjs').then((module) => module.default),
|
|
15
|
-
"platform": () => import('../chunks/platform.mjs').then((module) => module.default),
|
|
16
|
-
"app:create": () => import('../chunks/app-create.mjs').then((module) => module.default),
|
|
17
|
-
"module:create": () => import('../chunks/module-create.mjs').then((module) => module.default),
|
|
18
|
-
"module:folder": () => import('../chunks/module-folder.mjs').then((module) => module.default),
|
|
19
|
-
"module:move": () => import('../chunks/module-move.mjs').then((module) => module.default),
|
|
20
|
-
"package:rename": () => import('../chunks/package-rename.mjs').then((module) => module.default),
|
|
21
|
-
"add": () => import('../chunks/add2.mjs').then((module) => module.default),
|
|
22
|
-
"upgrade": () => import('../chunks/upgrade.mjs').then(function (n) { return n.a; }).then((module) => module.default),
|
|
23
|
-
"prepare": () => import('../chunks/prepare.mjs').then((module) => module.default)
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
async function main() {
|
|
27
|
-
await runMain(mainCmd);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { mainCmd as a, main as m };
|