@frigear-nu/cli 0.2.8 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -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:create <name> [--scope @acme]` | Scaffolds a Nuxt module in `packages/<name>`. |
18
- | `add <module...> [--app <app>]` | `pnpm add` in the app and adds the modules to its `nuxt.config`. |
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:folder <module> [--runtime]` | Turns `modules/foo.ts` into `modules/foo/index.ts`. |
21
- | `module:move <module> <destination> [--name <name>]` | Moves a local module or package folder and fixes relative paths. |
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
@@ -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.CgfNXZ_5.mjs';
5
- import { P as PlatformError, t as toPackageName, d as defineCommandArgs, c as templateArgs } from '../shared/cli.BgaCK7CK.mjs';
6
- import { e as exitWith, a as appsDirArg } from '../shared/cli.DM-mHY0i.mjs';
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';
@@ -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.BgaCK7CK.mjs';
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: true
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 modules = [...new Set(args._.map(String).map(resolveModuleName))];
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 added = await addModulesToConfig(configPath, modules).catch((error) => {
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
- ${modules.map((name) => ` '${name}',`).join("\n")}`);
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 homepage = (await readPackage(join(appDir, "node_modules", name)).catch(() => void 0))?.homepage;
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.CgfNXZ_5.mjs';
4
- export { r as resolveAppScope } from '../shared/cli.CgfNXZ_5.mjs';
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.BgaCK7CK.mjs';
7
- import { e as exitWith, a as appsDirArg } from '../shared/cli.DM-mHY0i.mjs';
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';
@@ -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.BgaCK7CK.mjs';
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 };
@@ -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.BgaCK7CK.mjs';
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';
@@ -1,8 +1,8 @@
1
1
  import { defineCommand } from 'citty';
2
2
  import consola from 'consola';
3
- import { i as initPlatform } from '../shared/cli.CsVNx740.mjs';
4
- import { P as PlatformError, d as defineCommandArgs } from '../shared/cli.BgaCK7CK.mjs';
5
- import { p as passThroughArgs, e as exitWith, a as appsDirArg } from '../shared/cli.DM-mHY0i.mjs';
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';
@@ -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.CsVNx740.mjs';
6
- import { f as findWorkspaceRoot, b as readPackage, r as resolveAppsDir, d as defineCommandArgs } from '../shared/cli.BgaCK7CK.mjs';
7
- import { e as exitWith, a as appsDirArg } from '../shared/cli.DM-mHY0i.mjs';
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.BgaCK7CK.mjs';
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: "module:create",
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:create");
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.BgaCK7CK.mjs';
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: "module:folder",
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:folder");
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:folder", {
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, w as workspaceGlobs, b as readPackage } from '../shared/cli.BgaCK7CK.mjs';
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: "module:move",
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:move");
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:move", {
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, e as workspacePackageDirs, b as readPackage, p as packageScope } from '../shared/cli.BgaCK7CK.mjs';
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';
@@ -5,7 +5,8 @@ import { readFile, writeFile, readdir, stat, mkdir, rename } from 'node:fs/promi
5
5
  import { join, basename, relative, dirname, resolve } from 'node:path';
6
6
  import { parseModule } 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.BgaCK7CK.mjs';
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";
@@ -358,6 +359,66 @@ const mcpPermission = {
358
359
  ]
359
360
  };
360
361
 
362
+ const PRELOAD_DOCS = `${DOCS}/modules/platform/module-kit/registries-and-menus#preload-providers`;
363
+ const moduleKitPreload = {
364
+ id: "module-kit-preload",
365
+ package: "@frigear-nu/module-kit",
366
+ since: "1.4.0",
367
+ title: "Bootstrap providers are preload providers",
368
+ docs: PRELOAD_DOCS,
369
+ rules: [
370
+ {
371
+ pattern: /\bregisterBootstrapProvider\b/g,
372
+ replace: "registerPreloadProvider",
373
+ 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."
374
+ },
375
+ {
376
+ pattern: /\bgetBootstrapProviders\b/g,
377
+ replace: "getPreloadProviders",
378
+ message: "`getBootstrapProviders` is `getPreloadProviders` (providers carry `area`, not `scope`)."
379
+ },
380
+ {
381
+ pattern: /\bdefineBootstrapRegistry\b/g,
382
+ message: "`defineBootstrapRegistry` is gone: the module that owns an area calls `servePreloadArea(nuxt, { area })`, which mounts `GET /api/<area>/preload`."
383
+ },
384
+ {
385
+ pattern: /#bootstrap\/providers\b/g,
386
+ replace: "#preload/providers",
387
+ message: "`#bootstrap/providers` is `#preload/providers`."
388
+ }
389
+ ]
390
+ };
391
+ const uiPreload = {
392
+ id: "ui-preload",
393
+ package: "@frigear-nu/ui",
394
+ since: "0.3.0",
395
+ title: "loadBootstrap is loadPreload",
396
+ docs: `${DOCS}/modules/interface/ui/composables#one-request-for-an-area-loadpreload`,
397
+ rules: [
398
+ {
399
+ pattern: /\bloadBootstrap\b/g,
400
+ replace: "loadPreload",
401
+ 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`."
402
+ },
403
+ { pattern: /\bresetBootstrap\b/g, replace: "resetPreload", message: "`resetBootstrap` is `resetPreload`." },
404
+ { pattern: /\buseBootstrapState\b/g, replace: "usePreloadState", message: "`useBootstrapState` is `usePreloadState`." },
405
+ { pattern: /\bBOOTSTRAP_TTL_MS\b/g, replace: "PRELOAD_TTL_MS", message: "`BOOTSTRAP_TTL_MS` is `PRELOAD_TTL_MS`." }
406
+ ]
407
+ };
408
+ const authBootstrapRoute = {
409
+ id: "auth-bootstrap-route",
410
+ package: "@frigear-nu/auth",
411
+ since: "0.7.0",
412
+ title: "/api/auth/bootstrap moved to the area owners",
413
+ docs: PRELOAD_DOCS,
414
+ rules: [
415
+ {
416
+ pattern: /\/api\/auth\/bootstrap\b|\bauthApi\.bootstrap\b/g,
417
+ 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."
418
+ }
419
+ ]
420
+ };
421
+
361
422
  const UPGRADING = `${DOCS}/get-started/upgrading`;
362
423
  const authRoutes = {
363
424
  id: "auth-routes",
@@ -523,30 +584,12 @@ const migrations = [
523
584
  accountPermission,
524
585
  usersPermissions,
525
586
  eventsTicketsPage,
526
- oauthServerApplicationsPage
587
+ oauthServerApplicationsPage,
588
+ moduleKitPreload,
589
+ uiPreload,
590
+ authBootstrapRoute
527
591
  ];
528
592
 
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
593
  const code = (text) => `\`${text.replace(/`/g, "'")}\``;
551
594
  const renderReport = ({ root, from, to, bumps, results, dryRun }) => {
552
595
  const at = (hit) => `${relative(root, hit.file)}:${hit.line}`;
package/dist/cli.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { m as main } from './shared/cli.BoJY7u-i.mjs';
2
+ import { m as main } from './shared/cli.d9yZ18RW.mjs';
3
3
  import 'citty';
4
+ import 'consola';
4
5
 
5
6
  await main();
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: citty.CommandDef<citty.ArgsDef>;
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
- export { APP_TEMPLATES, BUILTIN_PLATFORMS, BUILTIN_SECRETS, DEFAULT_ENV_DIRS, PLATFORMS, PlatformError, STARTERS, addPlatform, main as default, definePlatform, describeEnvResult, detectAppPlatform, fillPlaceholders, findTarget, generateSecret, _default as initCmd, initPlatform, isTemplateSource, listWorkspaceApps, mainCmd, mergeRootScripts, migrations, platformRegistry, platformScripts, prepareEnv, resolveAppScope, resolveAppsDir, resolveEnvConfig, resolvePlatform, resolvePlatformApp, resolveStarter, resolveTemplateSource, targetCommand, upgradeWorkspace };
467
- export type { AddPlatformOptions, AddPlatformResult, AppTemplate, AppsDir, EnvConfig, InitPlatformOptions, InitPlatformResult, Migration, NextStepsContext, Platform, PlatformDefinition, PlatformErrorCode, PlatformRegistry, PlatformTarget, PrepareEnvOptions, PrepareEnvResult, ResolvePlatformAppOptions, Rule, SecretGenerator, Starter, UpgradeOptions, WorkspaceApp };
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: citty.CommandDef<citty.ArgsDef>;
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
- export { APP_TEMPLATES, BUILTIN_PLATFORMS, BUILTIN_SECRETS, DEFAULT_ENV_DIRS, PLATFORMS, PlatformError, STARTERS, addPlatform, main as default, definePlatform, describeEnvResult, detectAppPlatform, fillPlaceholders, findTarget, generateSecret, _default as initCmd, initPlatform, isTemplateSource, listWorkspaceApps, mainCmd, mergeRootScripts, migrations, platformRegistry, platformScripts, prepareEnv, resolveAppScope, resolveAppsDir, resolveEnvConfig, resolvePlatform, resolvePlatformApp, resolveStarter, resolveTemplateSource, targetCommand, upgradeWorkspace };
467
- export type { AddPlatformOptions, AddPlatformResult, AppTemplate, AppsDir, EnvConfig, InitPlatformOptions, InitPlatformResult, Migration, NextStepsContext, Platform, PlatformDefinition, PlatformErrorCode, PlatformRegistry, PlatformTarget, PrepareEnvOptions, PrepareEnvResult, ResolvePlatformAppOptions, Rule, SecretGenerator, Starter, UpgradeOptions, WorkspaceApp };
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.BoJY7u-i.mjs';
1
+ export { m as default, a as mainCmd } from './shared/cli.d9yZ18RW.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.CgfNXZ_5.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._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.BgaCK7CK.mjs';
7
- export { d as detectAppPlatform, i as initPlatform, l as listWorkspaceApps, r as resolvePlatformApp, t as targetCommand } from './shared/cli.CsVNx740.mjs';
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, workspacePackageDirs 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, workspaceGlobs as w, rewritePins as x, movePatchedDependencies as y };
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.BgaCK7CK.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.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 };
@@ -1,4 +1,4 @@
1
- import { P as PlatformError } from './cli.BgaCK7CK.mjs';
1
+ import { P as PlatformError } from './cli.A6PoFRmM.mjs';
2
2
 
3
3
  const exitWith = (logger, error) => {
4
4
  if (error instanceof PlatformError) {
@@ -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.BgaCK7CK.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.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")) => {
@@ -0,0 +1,44 @@
1
+ import { defineCommand, runMain } from 'citty';
2
+ import consola from 'consola';
3
+
4
+ const version = "0.2.9";
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frigear-nu/cli",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "Frigear CLI: scaffold projects, apps and modules, and add Frigear modules to an app.",
@@ -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 };