@frigear-nu/cli 0.2.7 → 0.2.8

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.
@@ -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.DhcObGQf.mjs';
5
- import { P as PlatformError, t as toPackageName, d as defineCommandArgs, c as templateArgs } from '../shared/cli.B7bXD3w0.mjs';
6
- import { e as exitWith, a as appsDirArg } from '../shared/cli.Cbq-hdVL.mjs';
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';
7
7
  import 'pkg-types';
8
8
  import '../shared/cli.C-q4Gf2K.mjs';
9
9
  import 'nypm';
@@ -5,7 +5,7 @@ import { readFile, writeFile } from 'node:fs/promises';
5
5
  import { resolve, join, relative } from 'node:path';
6
6
  import { parseModule, generateCode } from 'magicast';
7
7
  import { getDefaultExportOptions, addNuxtModule } from 'magicast/helpers';
8
- import { b as readPackage, d as defineCommandArgs, f as findWorkspaceRoot, l as listDirs } from '../shared/cli.B7bXD3w0.mjs';
8
+ import { b as readPackage, d as defineCommandArgs, f as findWorkspaceRoot, l as listDirs } from '../shared/cli.BgaCK7CK.mjs';
9
9
  import { a as addDeps } from '../shared/cli.C-q4Gf2K.mjs';
10
10
  import 'scule';
11
11
  import 'pkg-types';
@@ -1,10 +1,10 @@
1
1
  import { defineCommand } from 'citty';
2
2
  import consola from 'consola';
3
- import { a as addPlatform } from '../shared/cli.DhcObGQf.mjs';
4
- export { r as resolveAppScope } from '../shared/cli.DhcObGQf.mjs';
3
+ import { a as addPlatform } from '../shared/cli.CgfNXZ_5.mjs';
4
+ export { r as resolveAppScope } from '../shared/cli.CgfNXZ_5.mjs';
5
5
  import { A as APP_TEMPLATES } from '../shared/cli.DnhGPz3G.mjs';
6
- import { d as defineCommandArgs, c as templateArgs } from '../shared/cli.B7bXD3w0.mjs';
7
- import { e as exitWith, a as appsDirArg } from '../shared/cli.Cbq-hdVL.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';
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.B7bXD3w0.mjs';
4
+ import { f as findWorkspaceRoot, d as defineCommandArgs } from '../shared/cli.BgaCK7CK.mjs';
5
5
  import 'node:fs';
6
6
  import 'node:fs/promises';
7
7
  import 'node:crypto';
@@ -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.B7bXD3w0.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.BgaCK7CK.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.fvLpSH0v.mjs';
4
- import { P as PlatformError, d as defineCommandArgs } from '../shared/cli.B7bXD3w0.mjs';
5
- import { p as passThroughArgs, e as exitWith, a as appsDirArg } from '../shared/cli.Cbq-hdVL.mjs';
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';
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.fvLpSH0v.mjs';
6
- import { f as findWorkspaceRoot, b as readPackage, r as resolveAppsDir, d as defineCommandArgs } from '../shared/cli.B7bXD3w0.mjs';
7
- import { e as exitWith, a as appsDirArg } from '../shared/cli.Cbq-hdVL.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';
8
8
  import '../shared/cli.B9jOPxYC.mjs';
9
9
  import 'giget';
10
10
  import 'node:fs/promises';
@@ -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.B7bXD3w0.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.BgaCK7CK.mjs';
4
4
  import { d as downloadTemplateToDir } from '../shared/cli.B9jOPxYC.mjs';
5
5
  import consola from 'consola';
6
6
  import 'scule';
@@ -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.B7bXD3w0.mjs';
6
+ import { d as defineCommandArgs, f as findWorkspaceRoot } from '../shared/cli.BgaCK7CK.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';
@@ -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.B7bXD3w0.mjs';
6
+ import { d as defineCommandArgs, f as findWorkspaceRoot, w as workspaceGlobs, b as readPackage } from '../shared/cli.BgaCK7CK.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';
@@ -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.B7bXD3w0.mjs';
6
+ import { d as defineCommandArgs, f as findWorkspaceRoot, e as workspacePackageDirs, b as readPackage, p as packageScope } from '../shared/cli.BgaCK7CK.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,7 @@ 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 { j as isBetween, k as duplicateVersions, s as sharedDuplicates, d as defineCommandArgs, f as findWorkspaceRoot, m as manifestFiles, n as findPins, o as currentVersions, q as compareVersions, u as rewritePins, v as movePatchedDependencies } from '../shared/cli.B7bXD3w0.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.BgaCK7CK.mjs';
9
9
  import { i as installDeps } from '../shared/cli.C-q4Gf2K.mjs';
10
10
 
11
11
  const DOCS = "https://docs.frigear.dev";
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { m as main } from './shared/cli.BH-_0Ga9.mjs';
2
+ import { m as main } from './shared/cli.BoJY7u-i.mjs';
3
3
  import 'citty';
4
4
 
5
5
  await main();
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- export { m as default, a as mainCmd } from './shared/cli.BH-_0Ga9.mjs';
1
+ export { m as default, a as mainCmd } from './shared/cli.BoJY7u-i.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.DhcObGQf.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';
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.B7bXD3w0.mjs';
7
- export { d as detectAppPlatform, i as initPlatform, l as listWorkspaceApps, r as resolvePlatformApp, t as targetCommand } from './shared/cli.fvLpSH0v.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';
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
9
  import 'citty';
10
10
  import 'consola';
@@ -244,6 +244,27 @@ const appGlobDirs = async (root) => {
244
244
  const globs = existsSync(yamlPath) ? workspaceGlobs(await readFile(yamlPath, "utf-8")) : [];
245
245
  return [...new Set(globs.map((glob) => glob.replace(/^\.\//, "").replace(/\/+$/, "")).filter((glob) => /^[^*]+\/\*{1,2}$/.test(glob)).map((glob) => glob.replace(/\/\*{1,2}$/, "")).filter((dir) => dir !== "packages"))];
246
246
  };
247
+ const workspacePackageNames = async (root, skip = []) => {
248
+ const yamlPath = join(root, "pnpm-workspace.yaml");
249
+ const globs = existsSync(yamlPath) ? workspaceGlobs(await readFile(yamlPath, "utf-8")) : [];
250
+ const parents = [...new Set(globs.map((glob) => glob.replace(/^\.\//, "").replace(/\/+$/, "")).filter((glob) => /^[^*!]+\/\*{1,2}$/.test(glob)).map((glob) => resolve(root, glob.replace(/\/\*{1,2}$/, ""))))];
251
+ const names = /* @__PURE__ */ new Set();
252
+ for (const parent of parents) {
253
+ for (const dir of await listDirs(parent)) {
254
+ if (skip.some((skipped) => resolve(skipped) === resolve(dir))) continue;
255
+ const name = (await readPackage(dir))?.name;
256
+ if (name) names.add(name);
257
+ }
258
+ }
259
+ return names;
260
+ };
261
+ const freePackageName = (name, taken) => {
262
+ if (!taken.has(name)) return name;
263
+ for (let n = 1; ; n++) {
264
+ const candidate = n === 1 ? `${name}-app` : `${name}-app-${n}`;
265
+ if (!taken.has(candidate)) return candidate;
266
+ }
267
+ };
247
268
  const resolveAppsDir = async ({ cwd, root, appsDir }) => {
248
269
  const globDirs = await appGlobDirs(root);
249
270
  const covered = (dir2) => globDirs.some((globDir) => resolve(root, globDir) === dir2);
@@ -260,4 +281,4 @@ const resolveAppsDir = async ({ cwd, root, appsDir }) => {
260
281
  return { dir, covered: covered(dir) };
261
282
  };
262
283
 
263
- export { PlatformError as P, renamePackage as a, readPackage as b, templateArgs as c, defineCommandArgs as d, workspacePackageDirs as e, findWorkspaceRoot as f, isInside as g, hasPackage as h, isEmptyDir as i, isBetween as j, duplicateVersions as k, listDirs as l, manifestFiles as m, findPins as n, currentVersions as o, packageScope as p, compareVersions as q, resolveAppsDir as r, sharedDuplicates as s, toPackageName as t, rewritePins as u, movePatchedDependencies as v, workspaceGlobs as w };
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 };
@@ -1,6 +1,6 @@
1
1
  import { defineCommand, runMain } from 'citty';
2
2
 
3
- const version = "0.2.7";
3
+ const version = "0.2.8";
4
4
  const pkg = {
5
5
  version: version};
6
6
 
@@ -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, l as listDirs, p as packageScope } from './cli.B7bXD3w0.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';
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")) => {
@@ -76,10 +76,17 @@ const addPlatform = async (options) => {
76
76
  await downloadTemplateToDir({ template: source, path: appDir }).catch((error) => {
77
77
  throw new PlatformError("DOWNLOAD_FAILED", `Failed to copy ${source} to ${appDir}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
78
78
  });
79
- const packageName = scope ? `${scope}/${appName}` : appName;
79
+ const wanted = scope ? `${scope}/${appName}` : appName;
80
+ let packageName = wanted;
80
81
  if (hasPackage(appDir)) {
81
82
  const path = join(appDir, "package.json");
82
83
  const pkg = await readPackageJSON(path);
84
+ const taken = await workspacePackageNames(root, [appDir]);
85
+ for (const deps of [pkg.dependencies, pkg.devDependencies, pkg.peerDependencies]) {
86
+ for (const name of Object.keys(deps ?? {})) taken.add(name);
87
+ }
88
+ packageName = freePackageName(wanted, taken);
89
+ if (packageName !== wanted) logger.warn(`${wanted} is already a package of the workspace or a dependency of the app: the app's package is named ${packageName}.`);
83
90
  const frigear = pkg.frigear && typeof pkg.frigear === "object" ? pkg.frigear : {};
84
91
  await writePackageJSON(path, { ...pkg, name: packageName, frigear: { ...frigear, platform: platform.name } });
85
92
  }
@@ -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, g as isInside } from './cli.B7bXD3w0.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';
7
7
  import { p as platformRegistry, f as findTarget } from './cli.DnhGPz3G.mjs';
8
8
 
9
9
  const detectAppPlatform = (registry, pkg) => {
@@ -1,4 +1,4 @@
1
- import { P as PlatformError } from './cli.B7bXD3w0.mjs';
1
+ import { P as PlatformError } from './cli.BgaCK7CK.mjs';
2
2
 
3
3
  const exitWith = (logger, error) => {
4
4
  if (error instanceof PlatformError) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frigear-nu/cli",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
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.",