@frigear-nu/cli 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,6 @@
1
1
  import * as citty from 'citty';
2
+ import { ConsolaInstance } from 'consola';
3
+ import { PackageJson } from 'pkg-types';
2
4
 
3
5
  declare const mainCmd: citty.CommandDef<citty.ArgsDef>;
4
6
  declare function main(): Promise<void>;
@@ -186,5 +188,227 @@ declare const upgradeWorkspace: (options: UpgradeOptions) => Promise<{
186
188
  */
187
189
  declare const migrations: Migration[];
188
190
 
189
- export { PLATFORMS, STARTERS, main as default, _default as initCmd, mainCmd, migrations, resolveStarter, upgradeWorkspace };
190
- export type { Migration, Platform, Rule, Starter, UpgradeOptions };
191
+ /** What `platform init <target>` runs in an app: the app's own `script` when it has it, else the `bin` command. */
192
+ interface PlatformTarget {
193
+ description?: string;
194
+ /** Other names for the target, e.g. `watchos` for `apple-watch`. */
195
+ aliases?: string[];
196
+ /** A script of the app's package.json, run with the workspace's package manager. */
197
+ script?: string;
198
+ /** A binary of the app's dependencies and its leading arguments, e.g. `['frigear-mobile', 'native']`. */
199
+ bin?: string[];
200
+ /** Arguments appended to the script or the binary. */
201
+ args?: string[];
202
+ }
203
+ interface NextStepsContext {
204
+ /** The app's folder name, e.g. `mobile`. */
205
+ appName: string;
206
+ /** The app's path relative to the workspace root, e.g. `apps/mobile`. */
207
+ appDir: string;
208
+ /** The app's package name, e.g. `@workspace/mobile`. */
209
+ packageName: string;
210
+ root: string;
211
+ /** Whether an app of the workspace runs `@frigear-nu/oauth-server`, so the new app can sign in there. */
212
+ hasOAuthServer: boolean;
213
+ }
214
+ interface PlatformDefinition {
215
+ /** `mobile`, `display`, ... */
216
+ name: string;
217
+ description?: string;
218
+ /** A template name (`web`, `mobile`, ... or a project's own) or a giget source. */
219
+ template?: string;
220
+ /** Folder name of the app when none is given; defaults to `name`. */
221
+ defaultAppName?: string;
222
+ /**
223
+ * Root package.json scripts added for each app of the platform. In keys and values `<name>` is the app's folder name
224
+ * and `<dir>` its path from the root (`./apps/mobile`). Existing scripts are never overwritten.
225
+ */
226
+ scripts?: Record<string, string>;
227
+ /** Printed after the app was added; `<name>`, `<dir>` and `<package>` are replaced in string steps. */
228
+ nextSteps?: string[] | ((context: NextStepsContext) => string[]);
229
+ /** What `platform init <target>` can do for apps of this platform. */
230
+ targets?: Record<string, PlatformTarget>;
231
+ /** Recognises an app of this platform that has no `frigear.platform` field in its package.json. */
232
+ detect?: (pkg: PackageJson) => boolean;
233
+ }
234
+ declare const definePlatform: (definition: PlatformDefinition) => PlatformDefinition;
235
+ /** App templates, as paths in the frigear-nu repository. */
236
+ declare const APP_TEMPLATES: {
237
+ readonly web: ".starters/workspace/apps/web";
238
+ readonly 'web-standalone': ".starters/mobile-standalone/apps/web";
239
+ readonly mobile: ".starters/mobile/apps/mobile";
240
+ readonly desktop: ".starters/desktop/apps/desktop";
241
+ };
242
+ type AppTemplate = keyof typeof APP_TEMPLATES;
243
+ /** The built-in platforms. A project adds its own, or overrides these, under `frigear.platforms` in the root package.json. */
244
+ declare const BUILTIN_PLATFORMS: Record<string, PlatformDefinition>;
245
+ interface PlatformRegistry {
246
+ platforms: Record<string, PlatformDefinition>;
247
+ /** Template names and their giget sources. */
248
+ templates: Record<string, string>;
249
+ }
250
+ /** The built-ins plus a project's own platforms and templates from `frigear` in its root package.json. */
251
+ declare const platformRegistry: (rootPkg?: PackageJson, ref?: string) => PlatformRegistry;
252
+ /** Whether a `--template` value is a giget source rather than a template name. */
253
+ declare const isTemplateSource: (value: string) => boolean;
254
+ /** The target of a platform by name or alias. */
255
+ declare const findTarget: (platform: PlatformDefinition, name: string) => {
256
+ id: string;
257
+ target: PlatformTarget;
258
+ } | undefined;
259
+
260
+ interface AddPlatformOptions {
261
+ /** Any folder of the workspace: the root, the apps folder, an app. */
262
+ cwd: string;
263
+ /** A platform name (`web`, `mobile`, `desktop`, a project's own, or any name with `template`), or a definition. */
264
+ platform: string | PlatformDefinition;
265
+ /** The app's folder name; defaults to the platform's `defaultAppName` or name. */
266
+ name?: string;
267
+ /** A template name or giget source, instead of the platform's own template. */
268
+ template?: string;
269
+ /** The folder apps go into: `auto` (default) or a path relative to `cwd`. */
270
+ appsDir?: string;
271
+ /** Branch or tag of the frigear-nu repository for the built-in templates. */
272
+ ref?: string;
273
+ /** Add the platform's scripts to the root package.json (default true). */
274
+ scripts?: boolean;
275
+ /** Install the workspace's dependencies afterwards (default true). */
276
+ install?: boolean;
277
+ /** Run the root `prepare:env` script afterwards, when there is one (default: same as `install`). */
278
+ prepareEnv?: boolean;
279
+ logger?: ConsolaInstance;
280
+ }
281
+ interface AddPlatformResult {
282
+ root: string;
283
+ /** The platform the app was added as. */
284
+ platform: string;
285
+ /** The template source the app was copied from. */
286
+ source: string;
287
+ appName: string;
288
+ /** Absolute path of the new app. */
289
+ appDir: string;
290
+ packageName: string;
291
+ appsDir: {
292
+ dir: string;
293
+ covered: boolean;
294
+ };
295
+ scripts: {
296
+ added: string[];
297
+ skipped: string[];
298
+ };
299
+ nextSteps: string[];
300
+ }
301
+ /** The scope the apps in `appsDir` use (`@workspace` in the starters), else the root package's scope. */
302
+ declare const resolveAppScope: (root: string, appsDir?: string) => Promise<string | undefined>;
303
+ /** The platform definition for a name or definition; an unknown name is an ad hoc platform when a template is given. */
304
+ declare const resolvePlatform: (registry: PlatformRegistry, platform: string | PlatformDefinition, template?: string) => PlatformDefinition;
305
+ /** The giget source for a template name or source. */
306
+ declare const resolveTemplateSource: (registry: PlatformRegistry, template: string) => string;
307
+ /** Replaces `<name>`, `<dir>` and `<package>` in a script name, command or step. */
308
+ declare const fillPlaceholders: (text: string, values: {
309
+ name: string;
310
+ dir: string;
311
+ package?: string;
312
+ }) => string;
313
+ /** The root scripts of a platform for one app, keyed by app name. */
314
+ declare const platformScripts: (platform: PlatformDefinition, appName: string, appDir: string) => {
315
+ [k: string]: string;
316
+ };
317
+ /** Adds scripts to the root package.json, keeping every script that is already there. */
318
+ declare const mergeRootScripts: (root: string, scripts: Record<string, string>) => Promise<{
319
+ added: string[];
320
+ skipped: string[];
321
+ }>;
322
+ /**
323
+ * Adds an app of a platform to the workspace: copies the template into `<appsDir>/<name>`, names the package in the
324
+ * workspace's scope, records the platform in its package.json (`frigear.platform`), adds the platform's root scripts
325
+ * and installs. Works from any folder of the workspace.
326
+ */
327
+ declare const addPlatform: (options: AddPlatformOptions) => Promise<AddPlatformResult>;
328
+
329
+ type PlatformErrorCode = 'NO_WORKSPACE' | 'OUTSIDE_ROOT' | 'APP_EXISTS' | 'UNKNOWN_PLATFORM' | 'UNKNOWN_TEMPLATE' | 'UNKNOWN_TARGET' | 'APP_NOT_FOUND' | 'APP_AMBIGUOUS' | 'DOWNLOAD_FAILED';
330
+ /** An error of `addPlatform` / `initPlatform`; `candidates` lists the choices when one has to be picked. */
331
+ declare class PlatformError extends Error {
332
+ readonly code: PlatformErrorCode;
333
+ readonly candidates?: string[];
334
+ constructor(code: PlatformErrorCode, message: string, options?: {
335
+ candidates?: string[];
336
+ cause?: unknown;
337
+ });
338
+ }
339
+
340
+ interface WorkspaceApp {
341
+ /** Folder name, e.g. `mobile`. */
342
+ name: string;
343
+ /** Absolute path. */
344
+ dir: string;
345
+ pkg: PackageJson;
346
+ /** The platform from `frigear.platform`, else detected from its dependencies. */
347
+ platform?: PlatformDefinition;
348
+ }
349
+ /** The platform of an app: its `frigear.platform` field, else the first platform whose `detect` matches (`web` last). */
350
+ declare const detectAppPlatform: (registry: PlatformRegistry, pkg: PackageJson) => PlatformDefinition | undefined;
351
+ /** The apps of the workspace (folders with a package.json in the apps folder) and their platforms. */
352
+ declare const listWorkspaceApps: (appsDir: string, registry: PlatformRegistry) => Promise<WorkspaceApp[]>;
353
+ interface ResolvePlatformAppOptions {
354
+ cwd: string;
355
+ root: string;
356
+ appsDir: string;
357
+ registry: PlatformRegistry;
358
+ target: string;
359
+ /** A folder name under the apps folder, or a path relative to `cwd`. */
360
+ app?: string;
361
+ }
362
+ /** The app to set a target up in: `app`, else the app `cwd` is in, else the only app whose platform has the target. */
363
+ declare const resolvePlatformApp: (options: ResolvePlatformAppOptions) => Promise<WorkspaceApp>;
364
+ interface InitPlatformOptions {
365
+ /** Any folder of the workspace. */
366
+ cwd: string;
367
+ /** `ios`, `android`, `apple-watch`, `tauri`, or a target of a project's own platform. */
368
+ target: string;
369
+ /** The app: a folder name under the apps folder, or a path. */
370
+ app?: string;
371
+ /** The folder apps live in: `auto` (default) or a path relative to `cwd`. */
372
+ appsDir?: string;
373
+ /** Extra arguments for the script or binary. */
374
+ args?: string[];
375
+ /** Only work out what would run. */
376
+ dryRun?: boolean;
377
+ logger?: ConsolaInstance;
378
+ }
379
+ interface InitPlatformResult {
380
+ root: string;
381
+ app: WorkspaceApp;
382
+ platform: string;
383
+ target: string;
384
+ /** What runs (or would run): `script <name> ...` or `exec <bin> ...`. */
385
+ command: {
386
+ kind: 'script' | 'exec';
387
+ name: string;
388
+ args: string[];
389
+ };
390
+ }
391
+ /** How a target runs in an app: its script when the app has it, else the binary. */
392
+ declare const targetCommand: (target: PlatformTarget, pkg: PackageJson, extra?: string[]) => InitPlatformResult["command"] | undefined;
393
+ /** Sets up a target (`ios`, `apple-watch`, `tauri`, ...) in an app of the workspace, through the app's own tooling. */
394
+ declare const initPlatform: (options: InitPlatformOptions) => Promise<InitPlatformResult>;
395
+
396
+ interface AppsDir {
397
+ /** Absolute path of the folder new apps go into. */
398
+ dir: string;
399
+ /** Whether a `pnpm-workspace.yaml` glob covers its subfolders; if not, pnpm will not install an app put there. */
400
+ covered: boolean;
401
+ }
402
+ /**
403
+ * The folder apps live in. `appsDir` (resolved against `cwd`) when given and not `auto`; else the apps folder `cwd` is
404
+ * in (so the command works from the root and from inside `apps/`); else `apps`, or the first other folder of a
405
+ * one-level `pnpm-workspace.yaml` glob that is not `packages`.
406
+ */
407
+ declare const resolveAppsDir: ({ cwd, root, appsDir }: {
408
+ cwd: string;
409
+ root: string;
410
+ appsDir?: string;
411
+ }) => Promise<AppsDir>;
412
+
413
+ export { APP_TEMPLATES, BUILTIN_PLATFORMS, PLATFORMS, PlatformError, STARTERS, addPlatform, main as default, definePlatform, detectAppPlatform, fillPlaceholders, findTarget, _default as initCmd, initPlatform, isTemplateSource, listWorkspaceApps, mainCmd, mergeRootScripts, migrations, platformRegistry, platformScripts, resolveAppScope, resolveAppsDir, resolvePlatform, resolvePlatformApp, resolveStarter, resolveTemplateSource, targetCommand, upgradeWorkspace };
414
+ export type { AddPlatformOptions, AddPlatformResult, AppTemplate, AppsDir, InitPlatformOptions, InitPlatformResult, Migration, NextStepsContext, Platform, PlatformDefinition, PlatformErrorCode, PlatformRegistry, PlatformTarget, ResolvePlatformAppOptions, Rule, Starter, UpgradeOptions, WorkspaceApp };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import * as citty from 'citty';
2
+ import { ConsolaInstance } from 'consola';
3
+ import { PackageJson } from 'pkg-types';
2
4
 
3
5
  declare const mainCmd: citty.CommandDef<citty.ArgsDef>;
4
6
  declare function main(): Promise<void>;
@@ -186,5 +188,227 @@ declare const upgradeWorkspace: (options: UpgradeOptions) => Promise<{
186
188
  */
187
189
  declare const migrations: Migration[];
188
190
 
189
- export { PLATFORMS, STARTERS, main as default, _default as initCmd, mainCmd, migrations, resolveStarter, upgradeWorkspace };
190
- export type { Migration, Platform, Rule, Starter, UpgradeOptions };
191
+ /** What `platform init <target>` runs in an app: the app's own `script` when it has it, else the `bin` command. */
192
+ interface PlatformTarget {
193
+ description?: string;
194
+ /** Other names for the target, e.g. `watchos` for `apple-watch`. */
195
+ aliases?: string[];
196
+ /** A script of the app's package.json, run with the workspace's package manager. */
197
+ script?: string;
198
+ /** A binary of the app's dependencies and its leading arguments, e.g. `['frigear-mobile', 'native']`. */
199
+ bin?: string[];
200
+ /** Arguments appended to the script or the binary. */
201
+ args?: string[];
202
+ }
203
+ interface NextStepsContext {
204
+ /** The app's folder name, e.g. `mobile`. */
205
+ appName: string;
206
+ /** The app's path relative to the workspace root, e.g. `apps/mobile`. */
207
+ appDir: string;
208
+ /** The app's package name, e.g. `@workspace/mobile`. */
209
+ packageName: string;
210
+ root: string;
211
+ /** Whether an app of the workspace runs `@frigear-nu/oauth-server`, so the new app can sign in there. */
212
+ hasOAuthServer: boolean;
213
+ }
214
+ interface PlatformDefinition {
215
+ /** `mobile`, `display`, ... */
216
+ name: string;
217
+ description?: string;
218
+ /** A template name (`web`, `mobile`, ... or a project's own) or a giget source. */
219
+ template?: string;
220
+ /** Folder name of the app when none is given; defaults to `name`. */
221
+ defaultAppName?: string;
222
+ /**
223
+ * Root package.json scripts added for each app of the platform. In keys and values `<name>` is the app's folder name
224
+ * and `<dir>` its path from the root (`./apps/mobile`). Existing scripts are never overwritten.
225
+ */
226
+ scripts?: Record<string, string>;
227
+ /** Printed after the app was added; `<name>`, `<dir>` and `<package>` are replaced in string steps. */
228
+ nextSteps?: string[] | ((context: NextStepsContext) => string[]);
229
+ /** What `platform init <target>` can do for apps of this platform. */
230
+ targets?: Record<string, PlatformTarget>;
231
+ /** Recognises an app of this platform that has no `frigear.platform` field in its package.json. */
232
+ detect?: (pkg: PackageJson) => boolean;
233
+ }
234
+ declare const definePlatform: (definition: PlatformDefinition) => PlatformDefinition;
235
+ /** App templates, as paths in the frigear-nu repository. */
236
+ declare const APP_TEMPLATES: {
237
+ readonly web: ".starters/workspace/apps/web";
238
+ readonly 'web-standalone': ".starters/mobile-standalone/apps/web";
239
+ readonly mobile: ".starters/mobile/apps/mobile";
240
+ readonly desktop: ".starters/desktop/apps/desktop";
241
+ };
242
+ type AppTemplate = keyof typeof APP_TEMPLATES;
243
+ /** The built-in platforms. A project adds its own, or overrides these, under `frigear.platforms` in the root package.json. */
244
+ declare const BUILTIN_PLATFORMS: Record<string, PlatformDefinition>;
245
+ interface PlatformRegistry {
246
+ platforms: Record<string, PlatformDefinition>;
247
+ /** Template names and their giget sources. */
248
+ templates: Record<string, string>;
249
+ }
250
+ /** The built-ins plus a project's own platforms and templates from `frigear` in its root package.json. */
251
+ declare const platformRegistry: (rootPkg?: PackageJson, ref?: string) => PlatformRegistry;
252
+ /** Whether a `--template` value is a giget source rather than a template name. */
253
+ declare const isTemplateSource: (value: string) => boolean;
254
+ /** The target of a platform by name or alias. */
255
+ declare const findTarget: (platform: PlatformDefinition, name: string) => {
256
+ id: string;
257
+ target: PlatformTarget;
258
+ } | undefined;
259
+
260
+ interface AddPlatformOptions {
261
+ /** Any folder of the workspace: the root, the apps folder, an app. */
262
+ cwd: string;
263
+ /** A platform name (`web`, `mobile`, `desktop`, a project's own, or any name with `template`), or a definition. */
264
+ platform: string | PlatformDefinition;
265
+ /** The app's folder name; defaults to the platform's `defaultAppName` or name. */
266
+ name?: string;
267
+ /** A template name or giget source, instead of the platform's own template. */
268
+ template?: string;
269
+ /** The folder apps go into: `auto` (default) or a path relative to `cwd`. */
270
+ appsDir?: string;
271
+ /** Branch or tag of the frigear-nu repository for the built-in templates. */
272
+ ref?: string;
273
+ /** Add the platform's scripts to the root package.json (default true). */
274
+ scripts?: boolean;
275
+ /** Install the workspace's dependencies afterwards (default true). */
276
+ install?: boolean;
277
+ /** Run the root `prepare:env` script afterwards, when there is one (default: same as `install`). */
278
+ prepareEnv?: boolean;
279
+ logger?: ConsolaInstance;
280
+ }
281
+ interface AddPlatformResult {
282
+ root: string;
283
+ /** The platform the app was added as. */
284
+ platform: string;
285
+ /** The template source the app was copied from. */
286
+ source: string;
287
+ appName: string;
288
+ /** Absolute path of the new app. */
289
+ appDir: string;
290
+ packageName: string;
291
+ appsDir: {
292
+ dir: string;
293
+ covered: boolean;
294
+ };
295
+ scripts: {
296
+ added: string[];
297
+ skipped: string[];
298
+ };
299
+ nextSteps: string[];
300
+ }
301
+ /** The scope the apps in `appsDir` use (`@workspace` in the starters), else the root package's scope. */
302
+ declare const resolveAppScope: (root: string, appsDir?: string) => Promise<string | undefined>;
303
+ /** The platform definition for a name or definition; an unknown name is an ad hoc platform when a template is given. */
304
+ declare const resolvePlatform: (registry: PlatformRegistry, platform: string | PlatformDefinition, template?: string) => PlatformDefinition;
305
+ /** The giget source for a template name or source. */
306
+ declare const resolveTemplateSource: (registry: PlatformRegistry, template: string) => string;
307
+ /** Replaces `<name>`, `<dir>` and `<package>` in a script name, command or step. */
308
+ declare const fillPlaceholders: (text: string, values: {
309
+ name: string;
310
+ dir: string;
311
+ package?: string;
312
+ }) => string;
313
+ /** The root scripts of a platform for one app, keyed by app name. */
314
+ declare const platformScripts: (platform: PlatformDefinition, appName: string, appDir: string) => {
315
+ [k: string]: string;
316
+ };
317
+ /** Adds scripts to the root package.json, keeping every script that is already there. */
318
+ declare const mergeRootScripts: (root: string, scripts: Record<string, string>) => Promise<{
319
+ added: string[];
320
+ skipped: string[];
321
+ }>;
322
+ /**
323
+ * Adds an app of a platform to the workspace: copies the template into `<appsDir>/<name>`, names the package in the
324
+ * workspace's scope, records the platform in its package.json (`frigear.platform`), adds the platform's root scripts
325
+ * and installs. Works from any folder of the workspace.
326
+ */
327
+ declare const addPlatform: (options: AddPlatformOptions) => Promise<AddPlatformResult>;
328
+
329
+ type PlatformErrorCode = 'NO_WORKSPACE' | 'OUTSIDE_ROOT' | 'APP_EXISTS' | 'UNKNOWN_PLATFORM' | 'UNKNOWN_TEMPLATE' | 'UNKNOWN_TARGET' | 'APP_NOT_FOUND' | 'APP_AMBIGUOUS' | 'DOWNLOAD_FAILED';
330
+ /** An error of `addPlatform` / `initPlatform`; `candidates` lists the choices when one has to be picked. */
331
+ declare class PlatformError extends Error {
332
+ readonly code: PlatformErrorCode;
333
+ readonly candidates?: string[];
334
+ constructor(code: PlatformErrorCode, message: string, options?: {
335
+ candidates?: string[];
336
+ cause?: unknown;
337
+ });
338
+ }
339
+
340
+ interface WorkspaceApp {
341
+ /** Folder name, e.g. `mobile`. */
342
+ name: string;
343
+ /** Absolute path. */
344
+ dir: string;
345
+ pkg: PackageJson;
346
+ /** The platform from `frigear.platform`, else detected from its dependencies. */
347
+ platform?: PlatformDefinition;
348
+ }
349
+ /** The platform of an app: its `frigear.platform` field, else the first platform whose `detect` matches (`web` last). */
350
+ declare const detectAppPlatform: (registry: PlatformRegistry, pkg: PackageJson) => PlatformDefinition | undefined;
351
+ /** The apps of the workspace (folders with a package.json in the apps folder) and their platforms. */
352
+ declare const listWorkspaceApps: (appsDir: string, registry: PlatformRegistry) => Promise<WorkspaceApp[]>;
353
+ interface ResolvePlatformAppOptions {
354
+ cwd: string;
355
+ root: string;
356
+ appsDir: string;
357
+ registry: PlatformRegistry;
358
+ target: string;
359
+ /** A folder name under the apps folder, or a path relative to `cwd`. */
360
+ app?: string;
361
+ }
362
+ /** The app to set a target up in: `app`, else the app `cwd` is in, else the only app whose platform has the target. */
363
+ declare const resolvePlatformApp: (options: ResolvePlatformAppOptions) => Promise<WorkspaceApp>;
364
+ interface InitPlatformOptions {
365
+ /** Any folder of the workspace. */
366
+ cwd: string;
367
+ /** `ios`, `android`, `apple-watch`, `tauri`, or a target of a project's own platform. */
368
+ target: string;
369
+ /** The app: a folder name under the apps folder, or a path. */
370
+ app?: string;
371
+ /** The folder apps live in: `auto` (default) or a path relative to `cwd`. */
372
+ appsDir?: string;
373
+ /** Extra arguments for the script or binary. */
374
+ args?: string[];
375
+ /** Only work out what would run. */
376
+ dryRun?: boolean;
377
+ logger?: ConsolaInstance;
378
+ }
379
+ interface InitPlatformResult {
380
+ root: string;
381
+ app: WorkspaceApp;
382
+ platform: string;
383
+ target: string;
384
+ /** What runs (or would run): `script <name> ...` or `exec <bin> ...`. */
385
+ command: {
386
+ kind: 'script' | 'exec';
387
+ name: string;
388
+ args: string[];
389
+ };
390
+ }
391
+ /** How a target runs in an app: its script when the app has it, else the binary. */
392
+ declare const targetCommand: (target: PlatformTarget, pkg: PackageJson, extra?: string[]) => InitPlatformResult["command"] | undefined;
393
+ /** Sets up a target (`ios`, `apple-watch`, `tauri`, ...) in an app of the workspace, through the app's own tooling. */
394
+ declare const initPlatform: (options: InitPlatformOptions) => Promise<InitPlatformResult>;
395
+
396
+ interface AppsDir {
397
+ /** Absolute path of the folder new apps go into. */
398
+ dir: string;
399
+ /** Whether a `pnpm-workspace.yaml` glob covers its subfolders; if not, pnpm will not install an app put there. */
400
+ covered: boolean;
401
+ }
402
+ /**
403
+ * The folder apps live in. `appsDir` (resolved against `cwd`) when given and not `auto`; else the apps folder `cwd` is
404
+ * in (so the command works from the root and from inside `apps/`); else `apps`, or the first other folder of a
405
+ * one-level `pnpm-workspace.yaml` glob that is not `packages`.
406
+ */
407
+ declare const resolveAppsDir: ({ cwd, root, appsDir }: {
408
+ cwd: string;
409
+ root: string;
410
+ appsDir?: string;
411
+ }) => Promise<AppsDir>;
412
+
413
+ export { APP_TEMPLATES, BUILTIN_PLATFORMS, PLATFORMS, PlatformError, STARTERS, addPlatform, main as default, definePlatform, detectAppPlatform, fillPlaceholders, findTarget, _default as initCmd, initPlatform, isTemplateSource, listWorkspaceApps, mainCmd, mergeRootScripts, migrations, platformRegistry, platformScripts, resolveAppScope, resolveAppsDir, resolvePlatform, resolvePlatformApp, resolveStarter, resolveTemplateSource, targetCommand, upgradeWorkspace };
414
+ export type { AddPlatformOptions, AddPlatformResult, AppTemplate, AppsDir, InitPlatformOptions, InitPlatformResult, Migration, NextStepsContext, Platform, PlatformDefinition, PlatformErrorCode, PlatformRegistry, PlatformTarget, ResolvePlatformAppOptions, Rule, Starter, UpgradeOptions, WorkspaceApp };
package/dist/index.mjs CHANGED
@@ -1,19 +1,23 @@
1
- export { m as default, a as mainCmd } from './shared/cli.B_BErT55.mjs';
1
+ export { m as default, a as mainCmd } from './shared/cli.DX_up8fP.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.DEhqG8Aw.mjs';
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.B8wGY3pU.mjs';
6
+ export { P as PlatformError, r as resolveAppsDir } from './shared/cli.CU1tZqxU.mjs';
7
+ export { d as detectAppPlatform, i as initPlatform, l as listWorkspaceApps, r as resolvePlatformApp, t as targetCommand } from './shared/cli.BVDx1SIR.mjs';
4
8
  import 'citty';
5
9
  import 'consola';
6
10
  import 'node:path';
7
- import './shared/cli.Cfkcp0w9.mjs';
8
- import 'scule';
9
- import 'node:fs';
10
- import 'node:fs/promises';
11
- import 'pkg-types';
12
- import './shared/cli.CkMCvUCp.mjs';
11
+ import './shared/cli.C-q4Gf2K.mjs';
13
12
  import 'nypm';
14
- import './shared/cli.C_0i5HKZ.mjs';
13
+ import 'tinyexec';
14
+ import './shared/cli.B9jOPxYC.mjs';
15
15
  import 'giget';
16
+ import 'node:fs/promises';
16
17
  import 'node:os';
18
+ import 'node:fs';
17
19
  import 'magicast';
18
20
  import 'magicast/helpers';
19
- import './shared/cli.DUmSgMcB.mjs';
21
+ import 'pkg-types';
22
+ import './shared/cli.BLUxtpPi.mjs';
23
+ import 'scule';
@@ -0,0 +1,127 @@
1
+ import { r as repoSource } from './cli.B9jOPxYC.mjs';
2
+
3
+ const definePlatform = (definition) => definition;
4
+ const APP_TEMPLATES = {
5
+ "web": ".starters/workspace/apps/web",
6
+ "web-standalone": ".starters/mobile-standalone/apps/web",
7
+ "mobile": ".starters/mobile/apps/mobile",
8
+ "desktop": ".starters/desktop/apps/desktop"
9
+ };
10
+ const dependsOn = (pkg, name) => !!(pkg.dependencies?.[name] ?? pkg.devDependencies?.[name]);
11
+ const clientSteps = (context, init, defaultName) => [
12
+ // A second app from the same template starts with the first one's app id and OAuth client id.
13
+ ...context.appName === defaultName ? [] : [` give it its own app id, name and client id in ${context.appDir}/identity.ts`],
14
+ context.hasOAuthServer ? ` register the client: import ${context.packageName}/identity in the OAuth server app's nuxt.config.ts and add it to oauthServer.clients (as in the multi-platform starter)` : ` set NUXT_PUBLIC_AUTHENTICATION_CLIENT_ISSUER (and _API_BASE) in ${context.appDir}/.env`,
15
+ ` pnpm ${context.appName}:${init}`
16
+ ];
17
+ const web = definePlatform({
18
+ name: "web",
19
+ description: "A Nuxt web app: users, auth, account and admin",
20
+ template: "web",
21
+ scripts: {
22
+ "dev:<name>": "pnpm --filter <dir> dev",
23
+ "db:generate": "pnpm --filter <dir> db:generate",
24
+ "db:migrate": "pnpm --filter <dir> db:migrate"
25
+ },
26
+ nextSteps: [" put your email in NUXT_ACL_ADMINS in <dir>/.env"],
27
+ detect: (pkg) => dependsOn(pkg, "nuxt") && !dependsOn(pkg, "@frigear-nu/mobile") && !dependsOn(pkg, "@frigear-nu/desktop")
28
+ });
29
+ const BUILTIN_PLATFORMS = {
30
+ "web": web,
31
+ "web-standalone": definePlatform({
32
+ ...web,
33
+ name: "web-standalone",
34
+ description: "The web app with an OAuth server and API for the mobile and desktop apps",
35
+ template: "web-standalone",
36
+ defaultAppName: "web",
37
+ detect: (pkg) => web.detect(pkg) && dependsOn(pkg, "@frigear-nu/oauth-server")
38
+ }),
39
+ "mobile": definePlatform({
40
+ name: "mobile",
41
+ description: "A Capacitor app on @frigear-nu/mobile (iOS, Android, Apple Watch)",
42
+ template: "mobile",
43
+ scripts: {
44
+ "dev:<name>": "pnpm --filter <dir> dev",
45
+ "<name>:native": "pnpm --filter <dir> run native",
46
+ "<name>:doctor": "pnpm --filter <dir> run doctor",
47
+ "<name>:watch": "pnpm --filter <dir> run watch",
48
+ "<name>:sync": "pnpm --filter <dir> run cap:sync",
49
+ "<name>:ios": "pnpm --filter <dir> run ios:run",
50
+ "<name>:ios:device": "pnpm --filter <dir> run ios:device",
51
+ "<name>:android": "pnpm --filter <dir> run android:run"
52
+ },
53
+ nextSteps: (context) => clientSteps(context, "native", "mobile"),
54
+ targets: {
55
+ "ios": { description: "The Xcode project (ios/)", script: "native", bin: ["frigear-mobile", "native"], args: ["--platform", "ios"] },
56
+ "android": { description: "The Android Studio project (android/)", script: "native", bin: ["frigear-mobile", "native"], args: ["--platform", "android"] },
57
+ "apple-watch": { description: "A watchOS companion app in the iOS project", aliases: ["watchos", "watch"], script: "watch", bin: ["frigear-mobile", "watch"] }
58
+ },
59
+ detect: (pkg) => dependsOn(pkg, "@frigear-nu/mobile")
60
+ }),
61
+ "desktop": definePlatform({
62
+ name: "desktop",
63
+ description: "A Tauri app on @frigear-nu/desktop (macOS, Windows, Linux)",
64
+ template: "desktop",
65
+ scripts: {
66
+ "dev:<name>": "pnpm --filter <dir> dev",
67
+ "<name>:doctor": "pnpm --filter <dir> run doctor",
68
+ "<name>:init": "pnpm --filter <dir> run native",
69
+ "<name>:sync": "pnpm --filter <dir> run native:sync",
70
+ "<name>:dev": "pnpm --filter <dir> run native:dev",
71
+ "<name>:build": "pnpm --filter <dir> run native:build",
72
+ "<name>:sidecar": "pnpm --filter <dir> run sidecar"
73
+ },
74
+ nextSteps: (context) => clientSteps(context, "init", "desktop"),
75
+ targets: {
76
+ tauri: { description: "The Tauri project (src-tauri/)", aliases: ["desktop"], script: "native", bin: ["frigear-desktop", "init"] }
77
+ },
78
+ detect: (pkg) => dependsOn(pkg, "@frigear-nu/desktop")
79
+ })
80
+ };
81
+ const record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
82
+ const strings = (value) => Object.fromEntries(Object.entries(record(value)).filter((entry) => typeof entry[1] === "string"));
83
+ const jsonTarget = (value) => {
84
+ const raw = record(value);
85
+ const list = (key) => Array.isArray(raw[key]) ? raw[key].filter((item) => typeof item === "string") : void 0;
86
+ return {
87
+ description: typeof raw.description === "string" ? raw.description : void 0,
88
+ script: typeof raw.script === "string" ? raw.script : void 0,
89
+ bin: list("bin"),
90
+ args: list("args"),
91
+ aliases: list("aliases")
92
+ };
93
+ };
94
+ const jsonPlatform = (name, value, base) => {
95
+ const raw = record(value);
96
+ const nextSteps = Array.isArray(raw.nextSteps) ? raw.nextSteps.filter((step) => typeof step === "string") : void 0;
97
+ const targets = Object.fromEntries(Object.entries(record(raw.targets)).map(([key, target]) => [key, jsonTarget(target)]));
98
+ return {
99
+ ...base,
100
+ name,
101
+ description: typeof raw.description === "string" ? raw.description : base?.description,
102
+ template: typeof raw.template === "string" ? raw.template : base?.template,
103
+ defaultAppName: typeof raw.defaultAppName === "string" ? raw.defaultAppName : base?.defaultAppName,
104
+ scripts: raw.scripts ? strings(raw.scripts) : base?.scripts,
105
+ nextSteps: nextSteps ?? base?.nextSteps,
106
+ targets: { ...base?.targets, ...targets }
107
+ };
108
+ };
109
+ const platformRegistry = (rootPkg, ref = "main") => {
110
+ const frigear = record(rootPkg?.frigear);
111
+ const templates = {
112
+ ...Object.fromEntries(Object.entries(APP_TEMPLATES).map(([name, path]) => [name, repoSource(path, ref)])),
113
+ ...strings(frigear.templates)
114
+ };
115
+ const platforms = { ...BUILTIN_PLATFORMS };
116
+ for (const [name, value] of Object.entries(record(frigear.platforms)))
117
+ platforms[name] = jsonPlatform(name, value, BUILTIN_PLATFORMS[name]);
118
+ return { platforms, templates };
119
+ };
120
+ const isTemplateSource = (value) => value.includes(":") || value.includes("/");
121
+ const findTarget = (platform, name) => {
122
+ const key = name.toLowerCase();
123
+ const entry = Object.entries(platform.targets ?? {}).find(([id, target]) => id === key || target.aliases?.includes(key));
124
+ return entry ? { id: entry[0], target: entry[1] } : void 0;
125
+ };
126
+
127
+ export { APP_TEMPLATES as A, BUILTIN_PLATFORMS as B, definePlatform as d, findTarget as f, isTemplateSource as i, platformRegistry as p };
@@ -26,7 +26,7 @@ const downloadTemplateToDir = async ({ template, path, cwd, force }) => {
26
26
  const message = error instanceof Error ? error.message : String(error);
27
27
  if (template.startsWith(FRIGEAR_REPO) && /\b(?:401|403|404)\b/.test(message) && !process.env.GIGET_AUTH) {
28
28
  throw new Error(`${message}
29
- While Frigear-nu/frigear-nu is not public, set GIGET_AUTH to a GitHub token that can read it, e.g. GIGET_AUTH=$(gh auth token).`, { cause: error });
29
+ GitHub refused the download; anonymous requests are rate limited. Set GIGET_AUTH to a GitHub token and retry, e.g. GIGET_AUTH=$(gh auth token).`, { cause: error });
30
30
  }
31
31
  throw error;
32
32
  });