@rebasepro/cli 0.31.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-setup-DqAcoDcn.js → agent-setup-Cg_zBWoW.js} +3 -3
- package/dist/{agent-setup-DqAcoDcn.js.map → agent-setup-Cg_zBWoW.js.map} +1 -1
- package/dist/api-TbmW33D7.js +275 -0
- package/dist/api-TbmW33D7.js.map +1 -0
- package/dist/{api-keys-eIUjMqWn.js → api-keys-fPQ55DCm.js} +151 -158
- package/dist/api-keys-fPQ55DCm.js.map +1 -0
- package/dist/{apps-DExO4PEl.js → apps-DBTRoOeP.js} +18 -13
- package/dist/apps-DBTRoOeP.js.map +1 -0
- package/dist/{args-CaCcrYE1.js → args-DHyrshtI.js} +3 -132
- package/dist/args-DHyrshtI.js.map +1 -0
- package/dist/{atlas-dev-database-DOCKk6ht.js → atlas-dev-database-D6h65f2x.js} +3 -3
- package/dist/{atlas-dev-database-DOCKk6ht.js.map → atlas-dev-database-D6h65f2x.js.map} +1 -1
- package/dist/{auth-ofQETpM5.js → auth-BpyYLEFY.js} +93 -12
- package/dist/auth-BpyYLEFY.js.map +1 -0
- package/dist/auth-session-B6aT0Dyj.js +371 -0
- package/dist/auth-session-B6aT0Dyj.js.map +1 -0
- package/dist/{backend-guard-C0mVkXBw.js → backend-guard-Cf8eMK_f.js} +2 -2
- package/dist/{backend-guard-C0mVkXBw.js.map → backend-guard-Cf8eMK_f.js.map} +1 -1
- package/dist/{branch-pointer-DMPyvZoK.js → branch-pointer-BJOF2Ubv.js} +1 -1
- package/dist/{build-CA5R07tw.js → build-BfdT-AUR.js} +12 -10
- package/dist/{build-CA5R07tw.js.map → build-BfdT-AUR.js.map} +1 -1
- package/dist/{bundle-DgILeA5b.js → bundle-CIiKGrte.js} +78 -12
- package/dist/bundle-CIiKGrte.js.map +1 -0
- package/dist/bundle.d.ts +31 -1
- package/dist/{cloud-CYMk92iG.js → cloud-MqnyPnmX.js} +1540 -1531
- package/dist/cloud-MqnyPnmX.js.map +1 -0
- package/dist/{cms-directories-BK3vcswg.js → cms-directories-BaV-Is9a.js} +2 -2
- package/dist/{cms-directories-BK3vcswg.js.map → cms-directories-BaV-Is9a.js.map} +1 -1
- package/dist/codemod/collections-to-tables/backend.d.ts +0 -2
- package/dist/codemod/collections-to-tables/customization.d.ts +2 -1
- package/dist/codemod/collections-to-tables/modules.d.ts +32 -0
- package/dist/codemod/collections-to-tables/plan-context.d.ts +7 -1
- package/dist/{command-D5lhW_-B.js → command-D9g46gg9.js} +68 -42
- package/dist/command-D9g46gg9.js.map +1 -0
- package/dist/commands/api-keys.d.ts +89 -52
- package/dist/commands/api.d.ts +114 -0
- package/dist/commands/auth-session.d.ts +94 -0
- package/dist/commands/auth.d.ts +1 -1
- package/dist/commands/cloud/alerts.d.ts +29 -0
- package/dist/commands/cloud/context.d.ts +8 -0
- package/dist/commands/cloud/debug.d.ts +16 -1
- package/dist/commands/cloud/deploy-hooks.d.ts +19 -0
- package/dist/commands/cloud/deploy.d.ts +25 -0
- package/dist/commands/cloud/env.d.ts +1 -0
- package/dist/commands/cloud/index.d.ts +5 -0
- package/dist/commands/cloud/maintenance.d.ts +26 -1
- package/dist/commands/cloud/not-served.d.ts +27 -0
- package/dist/commands/cloud/orgs.d.ts +5 -0
- package/dist/commands/cloud/resources.d.ts +82 -2
- package/dist/commands/cloud/runtime-logs.d.ts +57 -0
- package/dist/commands/cloud/settings.d.ts +3 -0
- package/dist/commands/cron.d.ts +68 -0
- package/dist/commands/data.d.ts +197 -0
- package/dist/commands/functions.d.ts +38 -0
- package/dist/commands/logs.d.ts +22 -0
- package/dist/commands/rls.d.ts +31 -0
- package/dist/commands/schema-reconcile.d.ts +2 -1
- package/dist/commands/schema-show.d.ts +38 -0
- package/dist/commands/storage-objects.d.ts +88 -0
- package/dist/commands/storage.d.ts +18 -2
- package/dist/commands/users.d.ts +147 -0
- package/dist/{consent-BXLIrMl8.js → consent-UV6ObCME.js} +2 -2
- package/dist/{consent-BXLIrMl8.js.map → consent-UV6ObCME.js.map} +1 -1
- package/dist/{console-DjThnr3f.js → console-BVoYOLAO.js} +6 -6
- package/dist/{console-DjThnr3f.js.map → console-BVoYOLAO.js.map} +1 -1
- package/dist/{context--JwaHaZp.js → context-BOMEoKxn.js} +80 -9
- package/dist/{context--JwaHaZp.js.map → context-BOMEoKxn.js.map} +1 -1
- package/dist/cron-CpUsQ739.js +298 -0
- package/dist/cron-CpUsQ739.js.map +1 -0
- package/dist/cron-ZRXsla0v.js +259 -0
- package/dist/cron-ZRXsla0v.js.map +1 -0
- package/dist/{daemon-w30PsdwV.js → daemon-D5gdG7gx.js} +3 -3
- package/dist/{daemon-w30PsdwV.js.map → daemon-D5gdG7gx.js.map} +1 -1
- package/dist/{daemon-entry-zOC1revO.js → daemon-entry--ummUJnk.js} +2 -2
- package/dist/{daemon-entry-zOC1revO.js.map → daemon-entry--ummUJnk.js.map} +1 -1
- package/dist/data-BJ9AZFUC.js +947 -0
- package/dist/data-BJ9AZFUC.js.map +1 -0
- package/dist/{db-Bz2RFGJj.js → db-D_iF4E-v.js} +38 -34
- package/dist/{db-Bz2RFGJj.js.map → db-D_iF4E-v.js.map} +1 -1
- package/dist/debug-nNbbxAeo.js +1114 -0
- package/dist/debug-nNbbxAeo.js.map +1 -0
- package/dist/{derive-C3ezmY-p.js → derive-Mky_u59_.js} +3 -3
- package/dist/{derive-C3ezmY-p.js.map → derive-Mky_u59_.js.map} +1 -1
- package/dist/{dev-D8TxrE_I.js → dev-bj6dEeSQ.js} +13 -13
- package/dist/{dev-D8TxrE_I.js.map → dev-bj6dEeSQ.js.map} +1 -1
- package/dist/dev-db/pull.d.ts +13 -3
- package/dist/{dev-preflight-DjvcV6SK.js → dev-preflight-BMOf2N6r.js} +2 -2
- package/dist/{dev-preflight-DjvcV6SK.js.map → dev-preflight-BMOf2N6r.js.map} +1 -1
- package/dist/{dev-server-BLxCbQEP.js → dev-server-2XHSHM_q.js} +2 -2
- package/dist/{dev-server-BLxCbQEP.js.map → dev-server-2XHSHM_q.js.map} +1 -1
- package/dist/{doctor-Du-mSxoE.js → doctor-2Jlau0Rm.js} +9 -8
- package/dist/{doctor-Du-mSxoE.js.map → doctor-2Jlau0Rm.js.map} +1 -1
- package/dist/{eject-Bhzd6hgb.js → eject-DK_M9kor.js} +4 -4
- package/dist/{eject-Bhzd6hgb.js.map → eject-DK_M9kor.js.map} +1 -1
- package/dist/{fold-static-CKewnAPX.js → fold-static-2t3UUX4z.js} +10 -6
- package/dist/fold-static-2t3UUX4z.js.map +1 -0
- package/dist/fold-static.d.ts +7 -0
- package/dist/functions-B4JR6EZL.js +120 -0
- package/dist/functions-B4JR6EZL.js.map +1 -0
- package/dist/{generate-view-CTOluXvH.js → generate-view-BMaLQm8H.js} +5 -5
- package/dist/{generate-view-CTOluXvH.js.map → generate-view-BMaLQm8H.js.map} +1 -1
- package/dist/{generate_sdk-De-aLC1L.js → generate_sdk-ByD-gTsK.js} +7 -7
- package/dist/{generate_sdk-De-aLC1L.js.map → generate_sdk-ByD-gTsK.js.map} +1 -1
- package/dist/index.es.js +123 -47
- package/dist/index.es.js.map +1 -1
- package/dist/{init-Dtl-IcXf.js → init-DHCe5mJ5.js} +59 -11
- package/dist/init-DHCe5mJ5.js.map +1 -0
- package/dist/{invoked-command-CG_rIa_o.js → invoked-command-FBeIBS8o.js} +2 -2
- package/dist/{invoked-command-CG_rIa_o.js.map → invoked-command-FBeIBS8o.js.map} +1 -1
- package/dist/last-dev-database-CBVkEUEl.js +2 -0
- package/dist/logs-CIgfLBsu.js +192 -0
- package/dist/logs-CIgfLBsu.js.map +1 -0
- package/dist/{manifest-C3uLDrrJ.js → manifest-RjqxfCpb.js} +114 -5
- package/dist/manifest-RjqxfCpb.js.map +1 -0
- package/dist/{migrate-VrKoi3nB.js → migrate-Cx8-Y4TG.js} +5 -4
- package/dist/{migrate-VrKoi3nB.js.map → migrate-Cx8-Y4TG.js.map} +1 -1
- package/dist/{normalize-imports-DwxqEMYq.js → normalize-imports-P86NVfpo.js} +3 -3
- package/dist/{normalize-imports-DwxqEMYq.js.map → normalize-imports-P86NVfpo.js.map} +1 -1
- package/dist/{path-flags-7O5uPBcQ.js → path-flags-ekLdkbra.js} +3 -3
- package/dist/{path-flags-7O5uPBcQ.js.map → path-flags-ekLdkbra.js.map} +1 -1
- package/dist/{prepare-Ccxspoj-.js → prepare-BaJe0Zik.js} +4 -4
- package/dist/{prepare-Ccxspoj-.js.map → prepare-BaJe0Zik.js.map} +1 -1
- package/dist/{project-CLcF5i8c.js → project-DALmhb5R.js} +2 -2
- package/dist/{project-CLcF5i8c.js.map → project-DALmhb5R.js.map} +1 -1
- package/dist/project-command-Cl9EZzjr.js +662 -0
- package/dist/project-command-Cl9EZzjr.js.map +1 -0
- package/dist/{project-schema-CsSOG2gE.js → project-schema-Dm6Jk0Y_.js} +4 -2
- package/dist/{project-schema-CsSOG2gE.js.map → project-schema-Dm6Jk0Y_.js.map} +1 -1
- package/dist/{pull-BMuiUyjb.js → pull-CTIsST6T.js} +66 -5
- package/dist/pull-CTIsST6T.js.map +1 -0
- package/dist/resolve-C36px9tR.js +2 -0
- package/dist/{resources-Dpfs2y8P.js → resources-Db3USuPO.js} +5 -5
- package/dist/{resources-Dpfs2y8P.js.map → resources-Db3USuPO.js.map} +1 -1
- package/dist/rls-BxrQ0P50.js +133 -0
- package/dist/rls-BxrQ0P50.js.map +1 -0
- package/dist/{schema-Dv6nHkb0.js → schema-_FzZEoB8.js} +54 -40
- package/dist/schema-_FzZEoB8.js.map +1 -0
- package/dist/{schema-dir-Cd1kvYbf.js → schema-dir-ChcYfWjP.js} +2 -2
- package/dist/{schema-dir-Cd1kvYbf.js.map → schema-dir-ChcYfWjP.js.map} +1 -1
- package/dist/schema-reconcile-DV14XY4o.js +2 -0
- package/dist/schema-show-h72UJ9zH.js +127 -0
- package/dist/schema-show-h72UJ9zH.js.map +1 -0
- package/dist/{skills-CXjA9TWw.js → skills-DQ2bZGkj.js} +6 -5
- package/dist/{skills-CXjA9TWw.js.map → skills-DQ2bZGkj.js.map} +1 -1
- package/dist/star-nudge.d.ts +28 -0
- package/dist/{start-Bwbtt2W5.js → start-Cjx4W0bJ.js} +7 -7
- package/dist/{start-Bwbtt2W5.js.map → start-Cjx4W0bJ.js.map} +1 -1
- package/dist/{status-BTgTWzlQ.js → status-CDBk25VO.js} +9 -9
- package/dist/{status-BTgTWzlQ.js.map → status-CDBk25VO.js.map} +1 -1
- package/dist/{storage-iTqj5-Av.js → storage-Clc8dLG8.js} +79 -36
- package/dist/storage-Clc8dLG8.js.map +1 -0
- package/dist/storage-objects-CfRKlTDe.js +279 -0
- package/dist/storage-objects-CfRKlTDe.js.map +1 -0
- package/dist/{telemetry-BP_1Cl9r.js → telemetry-DZU2-NCm.js} +5 -4
- package/dist/{telemetry-BP_1Cl9r.js.map → telemetry-DZU2-NCm.js.map} +1 -1
- package/dist/{telemetry-M3HjlyhZ.js → telemetry-EVtASbKb.js} +2 -2
- package/dist/{telemetry-M3HjlyhZ.js.map → telemetry-EVtASbKb.js.map} +1 -1
- package/dist/unknown-command-DnZ2uhGs.js +139 -0
- package/dist/unknown-command-DnZ2uhGs.js.map +1 -0
- package/dist/{upgrade-oZzJ13jM.js → upgrade-DhpUFb6p.js} +5 -5
- package/dist/{upgrade-oZzJ13jM.js.map → upgrade-DhpUFb6p.js.map} +1 -1
- package/dist/users-5PkqBY6R.js +561 -0
- package/dist/users-5PkqBY6R.js.map +1 -0
- package/dist/utils/project-command.d.ts +38 -0
- package/dist/utils/project-target.d.ts +193 -0
- package/dist/{verify-BkUVGLqo.js → verify-BdeqNb-V.js} +138 -12
- package/dist/verify-BdeqNb-V.js.map +1 -0
- package/dist/{version-Buyyo1ut.js → version-ONIeo7jl.js} +7 -2
- package/dist/{version-Buyyo1ut.js.map → version-ONIeo7jl.js.map} +1 -1
- package/package.json +10 -10
- package/dist/api-keys-eIUjMqWn.js.map +0 -1
- package/dist/apps-DExO4PEl.js.map +0 -1
- package/dist/args-CaCcrYE1.js.map +0 -1
- package/dist/auth-ofQETpM5.js.map +0 -1
- package/dist/bundle-DgILeA5b.js.map +0 -1
- package/dist/cloud-CYMk92iG.js.map +0 -1
- package/dist/command-D5lhW_-B.js.map +0 -1
- package/dist/fold-static-CKewnAPX.js.map +0 -1
- package/dist/init-Dtl-IcXf.js.map +0 -1
- package/dist/last-dev-database-Dc8cP01o.js +0 -2
- package/dist/manifest-C3uLDrrJ.js.map +0 -1
- package/dist/pull-BMuiUyjb.js.map +0 -1
- package/dist/resolve-BY7bSFRT.js +0 -2
- package/dist/schema-Dv6nHkb0.js.map +0 -1
- package/dist/schema-reconcile-CjxLaRHB.js +0 -2
- package/dist/storage-iTqj5-Av.js.map +0 -1
- package/dist/verify-BkUVGLqo.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as loadManifest } from "./manifest-
|
|
1
|
+
import { b as loadManifest } from "./manifest-RjqxfCpb.js";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
//#region src/utils/cms-directories.ts
|
|
@@ -30,4 +30,4 @@ function cmsDirectories(projectRoot) {
|
|
|
30
30
|
//#endregion
|
|
31
31
|
export { cmsDirectories as t };
|
|
32
32
|
|
|
33
|
-
//# sourceMappingURL=cms-directories-
|
|
33
|
+
//# sourceMappingURL=cms-directories-BaV-Is9a.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms-directories-
|
|
1
|
+
{"version":3,"file":"cms-directories-BaV-Is9a.js","names":[],"sources":["../src/utils/cms-directories.ts"],"sourcesContent":["/**\n * Where a project keeps its table customizations.\n *\n * Its own module, outside `commands/`: the bundler reads it too, and nothing\n * under `commands/` may sit on the CLI's startup import graph\n * (`cli-startup-imports.test.ts`).\n */\nimport fs from \"fs\";\nimport path from \"path\";\nimport { loadManifest } from \"../manifest\";\n\n/**\n * The directories that hold the project's table customizations: `src/cms` of\n * each static app `rebase.json` declares, and `frontend/src/cms`, the layout\n * `rebase init` writes. Only those that exist; none for a headless project.\n */\nexport function cmsDirectories(projectRoot: string): string[] {\n const roots = new Set<string>([\"frontend\"]);\n try {\n const { manifest } = loadManifest(projectRoot);\n for (const app of Object.values(manifest.apps)) {\n if (app.type === \"static\" && typeof app.root === \"string\") roots.add(app.root);\n }\n } catch {\n // No rebase.json, or one another command reports: the conventional layout.\n }\n const out: string[] = [];\n for (const root of roots) {\n const dir = path.resolve(projectRoot, root, \"src\", \"cms\");\n if (fs.existsSync(dir) && fs.statSync(dir).isDirectory() && !out.includes(dir)) out.push(dir);\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAgB,eAAe,aAA+B;CAC1D,MAAM,wBAAQ,IAAI,IAAY,CAAC,UAAU,CAAC;CAC1C,IAAI;EACA,MAAM,EAAE,aAAa,aAAa,WAAW;EAC7C,KAAK,MAAM,OAAO,OAAO,OAAO,SAAS,IAAI,GACzC,IAAI,IAAI,SAAS,YAAY,OAAO,IAAI,SAAS,UAAU,MAAM,IAAI,IAAI,IAAI;CAErF,QAAQ,CAER;CACA,MAAM,MAAgB,CAAC;CACvB,KAAK,MAAM,QAAQ,OAAO;EACtB,MAAM,MAAM,KAAK,QAAQ,aAAa,MAAM,OAAO,KAAK;EACxD,IAAI,GAAG,WAAW,GAAG,KAAK,GAAG,SAAS,GAAG,CAAC,CAAC,YAAY,KAAK,CAAC,IAAI,SAAS,GAAG,GAAG,IAAI,KAAK,GAAG;CAChG;CACA,OAAO;AACX"}
|
|
@@ -34,5 +34,3 @@ export interface BackendPlanInput {
|
|
|
34
34
|
export declare function nameTables(entries: readonly CollectionEntry[], defs: readonly (AnyTableDef | AnyViewDef)[], schemaDir: string): Map<string, TableName>;
|
|
35
35
|
/** Plan the backend schema modules. */
|
|
36
36
|
export declare function planBackend(plan: PlanContext, input: BackendPlanInput, names: Map<string, TableName>): void;
|
|
37
|
-
/** The relative module path of a table, from a file in another directory. */
|
|
38
|
-
export declare function tableImportPath(fromFile: string, table: TableName): string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LegacyEnumValues, LiftNote } from "@rebasepro/common/migrate";
|
|
2
2
|
import type { PathSegment } from "./ast.js";
|
|
3
|
+
import { type GeneratedSpecifierStyle } from "./modules.js";
|
|
3
4
|
import type { CollectionEntry, PlanContext } from "./plan-context.js";
|
|
4
5
|
import type { TableName } from "./backend.js";
|
|
5
6
|
/** The keys whose string value is a component path (the Vite plugin's `LAZY_COMPONENT_KEYS`). */
|
|
@@ -44,4 +45,4 @@ export declare function printCmsIndex(cmsDir: string, customizations: readonly {
|
|
|
44
45
|
}[], external: readonly {
|
|
45
46
|
identifier: string;
|
|
46
47
|
file: string;
|
|
47
|
-
}[]): string;
|
|
48
|
+
}[], style: GeneratedSpecifierStyle): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SourceFile } from "ts-morph";
|
|
1
2
|
import type { AstContext, ImportUse } from "./ast.js";
|
|
2
3
|
/** Which side of the split a file lives on. */
|
|
3
4
|
export type Side = "backend" | "frontend";
|
|
@@ -18,6 +19,37 @@ export interface ResolvedSpecifier {
|
|
|
18
19
|
export declare function resolveRelative(fromFile: string, specifier: string): ResolvedSpecifier;
|
|
19
20
|
/** A relative specifier from `fromFile` to `target`, written in `style`. */
|
|
20
21
|
export declare function writeSpecifier(fromFile: string, target: string, style: SpecifierStyle): string;
|
|
22
|
+
/**
|
|
23
|
+
* How the relative imports the codemod writes itself end — the schema index,
|
|
24
|
+
* a table's import of a related table, a customization's type import of its
|
|
25
|
+
* table: `"js"` (`./users.js`) or `"extensionless"` (`./users`).
|
|
26
|
+
*
|
|
27
|
+
* A project whose backend is built with a plain `tsc` (NodeNext) and run on
|
|
28
|
+
* Node needs `"js"`: Node's ESM loader resolves no relative import without
|
|
29
|
+
* its extension. `rebase build` and tsx resolve either spelling.
|
|
30
|
+
*/
|
|
31
|
+
export type GeneratedSpecifierStyle = "js" | "extensionless";
|
|
32
|
+
/**
|
|
33
|
+
* The {@link GeneratedSpecifierStyle} of a project, from the module specifiers
|
|
34
|
+
* its legacy collection sources write (the collection files and the
|
|
35
|
+
* collections index): `"js"` when more of their relative specifiers end in
|
|
36
|
+
* a JavaScript extension (`./users.js`) than in none (`./users`, `../lib`);
|
|
37
|
+
* `"extensionless"`, the house style, otherwise — a tie, or no relative
|
|
38
|
+
* import at all. A specifier with another extension (`./labels.json`,
|
|
39
|
+
* `./users.schema`) says nothing either way.
|
|
40
|
+
*
|
|
41
|
+
* @param specifiers every module specifier the sources import or re-export from, package names included
|
|
42
|
+
*/
|
|
43
|
+
export declare function projectSpecifierStyle(specifiers: readonly string[]): GeneratedSpecifierStyle;
|
|
44
|
+
/** The module specifiers a file imports and re-exports from, as written. */
|
|
45
|
+
export declare function writtenSpecifiers(sourceFile: SourceFile): string[];
|
|
46
|
+
/**
|
|
47
|
+
* The relative specifier of an import the codemod writes, from `fromFile` to
|
|
48
|
+
* the module `target`, in the project's {@link GeneratedSpecifierStyle}: for
|
|
49
|
+
* `users.ts`, `./users` or `./users.js`. A JavaScript target keeps its own
|
|
50
|
+
* extension in either style.
|
|
51
|
+
*/
|
|
52
|
+
export declare function generatedSpecifier(fromFile: string, target: string, style: GeneratedSpecifierStyle): string;
|
|
21
53
|
/** One helper module copied out of `config/`. */
|
|
22
54
|
export interface HelperCopy {
|
|
23
55
|
/** Where it was, absolute. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SourceFile } from "ts-morph";
|
|
2
2
|
import type { LegacyCollectionConfig } from "@rebasepro/common/migrate";
|
|
3
3
|
import type { AstContext, CollectionSite } from "./ast.js";
|
|
4
|
-
import type { Relocator } from "./modules.js";
|
|
4
|
+
import type { GeneratedSpecifierStyle, Relocator } from "./modules.js";
|
|
5
5
|
import type { SplitConstant } from "./split-constants.js";
|
|
6
6
|
import type { ManualStep, Note, Refusal } from "./types.js";
|
|
7
7
|
/** One legacy collection with everything the planners read about it. */
|
|
@@ -22,6 +22,12 @@ export interface PlanContext {
|
|
|
22
22
|
root: string;
|
|
23
23
|
ast: AstContext;
|
|
24
24
|
relocator: Relocator;
|
|
25
|
+
/**
|
|
26
|
+
* How every relative import the run writes itself ends (`./users` or
|
|
27
|
+
* `./users.js`): as the legacy collection sources write theirs, decided
|
|
28
|
+
* once from them (`projectSpecifierStyle`).
|
|
29
|
+
*/
|
|
30
|
+
specifierStyle: GeneratedSpecifierStyle;
|
|
25
31
|
/** The frontend app's root directory, absolute, when the project has one. */
|
|
26
32
|
frontendDir?: string;
|
|
27
33
|
/** Planned files: absolute path → content. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as createSchemaModuleImporter } from "./import-schema-module-Df67TIWj.js";
|
|
2
|
-
import { o as isAgentKey, t as AGENTS } from "./skills-
|
|
3
|
-
import { r as BACKEND_GUARD_SNIPPET, t as BACKEND_GUARD_EXPORT } from "./backend-guard-
|
|
2
|
+
import { o as isAgentKey, t as AGENTS } from "./skills-DQ2bZGkj.js";
|
|
3
|
+
import { r as BACKEND_GUARD_SNIPPET, t as BACKEND_GUARD_EXPORT } from "./backend-guard-Cf8eMK_f.js";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import { isViewDef, resolveResourceRefs } from "@rebasepro/types";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
@@ -831,6 +831,45 @@ function writeSpecifier(fromFile, target, style) {
|
|
|
831
831
|
return relative;
|
|
832
832
|
}
|
|
833
833
|
/**
|
|
834
|
+
* The {@link GeneratedSpecifierStyle} of a project, from the module specifiers
|
|
835
|
+
* its legacy collection sources write (the collection files and the
|
|
836
|
+
* collections index): `"js"` when more of their relative specifiers end in
|
|
837
|
+
* a JavaScript extension (`./users.js`) than in none (`./users`, `../lib`);
|
|
838
|
+
* `"extensionless"`, the house style, otherwise — a tie, or no relative
|
|
839
|
+
* import at all. A specifier with another extension (`./labels.json`,
|
|
840
|
+
* `./users.schema`) says nothing either way.
|
|
841
|
+
*
|
|
842
|
+
* @param specifiers every module specifier the sources import or re-export from, package names included
|
|
843
|
+
*/
|
|
844
|
+
function projectSpecifierStyle(specifiers) {
|
|
845
|
+
let withExtension = 0;
|
|
846
|
+
let without = 0;
|
|
847
|
+
for (const specifier of specifiers) {
|
|
848
|
+
if (!/^\.\.?(\/|$)/.test(specifier)) continue;
|
|
849
|
+
const last = specifier.split("/").pop() ?? "";
|
|
850
|
+
if (/\.[mc]?jsx?$/.test(last)) withExtension++;
|
|
851
|
+
else if (last === "" || last === "." || last === ".." || !last.includes(".")) without++;
|
|
852
|
+
}
|
|
853
|
+
return withExtension > without ? "js" : "extensionless";
|
|
854
|
+
}
|
|
855
|
+
/** The module specifiers a file imports and re-exports from, as written. */
|
|
856
|
+
function writtenSpecifiers(sourceFile) {
|
|
857
|
+
return [...sourceFile.getImportDeclarations().map((declaration) => declaration.getModuleSpecifierValue()), ...sourceFile.getExportDeclarations().flatMap((declaration) => declaration.getModuleSpecifierValue() ?? [])];
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* The relative specifier of an import the codemod writes, from `fromFile` to
|
|
861
|
+
* the module `target`, in the project's {@link GeneratedSpecifierStyle}: for
|
|
862
|
+
* `users.ts`, `./users` or `./users.js`. A JavaScript target keeps its own
|
|
863
|
+
* extension in either style.
|
|
864
|
+
*/
|
|
865
|
+
function generatedSpecifier(fromFile, target, style) {
|
|
866
|
+
const typescript = /\.(tsx?|mts)$/.exec(target);
|
|
867
|
+
let relative = toPosix(path.relative(path.dirname(fromFile), typescript ? target.slice(0, -typescript[0].length) : target));
|
|
868
|
+
if (!relative.startsWith("../")) relative = `./${relative}`;
|
|
869
|
+
if (style === "extensionless" || !typescript) return relative;
|
|
870
|
+
return `${relative}${typescript[1] === "mts" ? ".mjs" : ".js"}`;
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
834
873
|
* Moves specifiers and collects the helper copies they need. One per run, so
|
|
835
874
|
* a helper used by several files is copied once per side.
|
|
836
875
|
*/
|
|
@@ -1543,11 +1582,11 @@ function planBackend(plan, input, names) {
|
|
|
1543
1582
|
});
|
|
1544
1583
|
const ordered = [...input.order.map((slug) => names.get(slug)).filter((value) => value !== void 0)];
|
|
1545
1584
|
for (const name of names.values()) if (!ordered.includes(name)) ordered.push(name);
|
|
1546
|
-
const
|
|
1585
|
+
const indexFile = path.join(schemaDir, "index.ts");
|
|
1586
|
+
planFile(plan, indexFile, printIndexModule(ordered.map((name) => ({
|
|
1547
1587
|
identifier: name.identifier,
|
|
1548
|
-
importPath:
|
|
1549
|
-
})), lift.defaultRls !== void 0 ? { defaultRls: lift.defaultRls } : {});
|
|
1550
|
-
planFile(plan, path.join(schemaDir, "index.ts"), index, "the schema index");
|
|
1588
|
+
importPath: generatedSpecifier(indexFile, name.file, plan.specifierStyle)
|
|
1589
|
+
})), lift.defaultRls !== void 0 ? { defaultRls: lift.defaultRls } : {}), "the schema index");
|
|
1551
1590
|
}
|
|
1552
1591
|
function planTableModule(plan, entry, def, name, names) {
|
|
1553
1592
|
const collection = entry.collection;
|
|
@@ -1677,7 +1716,7 @@ function planTableModule(plan, entry, def, name, names) {
|
|
|
1677
1716
|
if (!found) throw new RelocationError(entry.file, `a relation points at "${target.slug}", which is not a collection file in ${relativeToRoot(plan, path.dirname(entry.file))}. Move that collection into the directory (or drop the relation) and run the codemod again.`);
|
|
1678
1717
|
return {
|
|
1679
1718
|
identifier: found.identifier,
|
|
1680
|
-
importPath:
|
|
1719
|
+
importPath: generatedSpecifier(name.file, found.file, plan.specifierStyle),
|
|
1681
1720
|
table: found.table,
|
|
1682
1721
|
kind: found.kind === "view" ? "view" : "table"
|
|
1683
1722
|
};
|
|
@@ -1767,12 +1806,6 @@ function fileHeader(plan, entry) {
|
|
|
1767
1806
|
if (!first || !plan.ast.tsm.Node.isImportDeclaration(first)) return [];
|
|
1768
1807
|
return leadingComments(first);
|
|
1769
1808
|
}
|
|
1770
|
-
/** The relative module path of a table, from a file in another directory. */
|
|
1771
|
-
function tableImportPath(fromFile, table) {
|
|
1772
|
-
let relative = toPosix(path.relative(path.dirname(fromFile), table.file.replace(/\.ts$/, "")));
|
|
1773
|
-
if (!relative.startsWith(".")) relative = `./${relative}`;
|
|
1774
|
-
return relative;
|
|
1775
|
-
}
|
|
1776
1809
|
//#endregion
|
|
1777
1810
|
//#region src/codemod/collections-to-tables/vocabulary.ts
|
|
1778
1811
|
/** A collection's `admin` keys → `customizeTable` options. */
|
|
@@ -2524,11 +2557,6 @@ async function findSplitConstants(plan, entries, importModule, cmsDir) {
|
|
|
2524
2557
|
function printedIds(constant) {
|
|
2525
2558
|
return `[${constant.ids.map((id) => typeof id === "string" ? printStringLiteral(id) : String(id)).join(", ")}]`;
|
|
2526
2559
|
}
|
|
2527
|
-
function specifierFrom(fromFile, target) {
|
|
2528
|
-
let relative = toPosix(path.relative(path.dirname(fromFile), target.replace(/\.(tsx?|mts)$/, "")));
|
|
2529
|
-
if (!relative.startsWith(".")) relative = `./${relative}`;
|
|
2530
|
-
return relative;
|
|
2531
|
-
}
|
|
2532
2560
|
/** Insert an import line after a module's import block. */
|
|
2533
2561
|
function addImport(content, line) {
|
|
2534
2562
|
if (content.includes(line)) return content;
|
|
@@ -2555,7 +2583,7 @@ function planSplitConstants(plan, constants, tableFiles) {
|
|
|
2555
2583
|
].join("\n"));
|
|
2556
2584
|
planFile(plan, group[0].backendFile, `${backend.join("\n\n")}\n`, `values of ${legacy}`);
|
|
2557
2585
|
const frontendFile = group[0].frontendFile;
|
|
2558
|
-
if (frontendFile) planFile(plan, frontendFile, `${`import type { ${group.map((constant) => constant.typeName).join(", ")} } from ${JSON.stringify(
|
|
2586
|
+
if (frontendFile) planFile(plan, frontendFile, `${`import type { ${group.map((constant) => constant.typeName).join(", ")} } from ${JSON.stringify(generatedSpecifier(frontendFile, group[0].backendFile, plan.specifierStyle))};`}\n\n${group.map((constant) => [
|
|
2559
2587
|
`/** What the panel calls each value of \`${constant.legacyName}\` (${legacy}); the values are the backend's. */`,
|
|
2560
2588
|
`export const ${constant.labelsName}: Record<${constant.typeName}, string> = {`,
|
|
2561
2589
|
Object.entries(constant.labels).map(([id, label]) => ` ${/^[A-Za-z_$][\w$]*$/.test(id) ? id : JSON.stringify(id)}: ${printStringLiteral(label)}`).join(",\n"),
|
|
@@ -2570,7 +2598,7 @@ function planSplitConstants(plan, constants, tableFiles) {
|
|
|
2570
2598
|
const printed = printedIds(constant);
|
|
2571
2599
|
if (!content.includes(printed)) continue;
|
|
2572
2600
|
content = content.split(printed).join(constant.valuesName);
|
|
2573
|
-
content = addImport(content, `import { ${constant.valuesName} } from ${JSON.stringify(
|
|
2601
|
+
content = addImport(content, `import { ${constant.valuesName} } from ${JSON.stringify(generatedSpecifier(tableFile, constant.backendFile, plan.specifierStyle))};`);
|
|
2574
2602
|
}
|
|
2575
2603
|
if (content !== planned.content) plan.files.set(tableFile, {
|
|
2576
2604
|
...planned,
|
|
@@ -3087,8 +3115,7 @@ function applyFieldNote(plan, builder, item, fields) {
|
|
|
3087
3115
|
case "enum": {
|
|
3088
3116
|
const constant = constantForEnum(plan.splitConstants ?? [], builder.entry.file, item.value);
|
|
3089
3117
|
if (constant?.frontendFile) {
|
|
3090
|
-
|
|
3091
|
-
if (!specifier.startsWith(".")) specifier = `./${specifier}`;
|
|
3118
|
+
const specifier = generatedSpecifier(builder.file, constant.frontendFile, plan.specifierStyle);
|
|
3092
3119
|
builder.libImports.set(specifier, /* @__PURE__ */ new Set([...builder.libImports.get(specifier) ?? [], constant.labelsName]));
|
|
3093
3120
|
target.enumLabels = new RawSource(constant.labelsName);
|
|
3094
3121
|
return;
|
|
@@ -3409,7 +3436,7 @@ function printModule(plan, builder, options) {
|
|
|
3409
3436
|
const componentLines = [...builder.componentImports].map(([local, { specifier, imported }]) => imported === "default" ? `import ${local} from ${JSON.stringify(specifier)};` : `import { ${imported === local ? local : `${imported} as ${local}`} } from ${JSON.stringify(specifier)};`);
|
|
3410
3437
|
const imports = [
|
|
3411
3438
|
`import { customizeTable } from "@rebasepro/cms";`,
|
|
3412
|
-
`import type { ${name.identifier} } from ${JSON.stringify(
|
|
3439
|
+
`import type { ${name.identifier} } from ${JSON.stringify(generatedSpecifier(file, name.file, plan.specifierStyle))};`,
|
|
3413
3440
|
...componentLines,
|
|
3414
3441
|
...[...builder.libImports].map(([specifier, imported]) => `import { ${[...imported].join(", ")} } from ${JSON.stringify(specifier)};`),
|
|
3415
3442
|
...carriedImports
|
|
@@ -3454,12 +3481,10 @@ function brandAdditionalFieldKeys(options) {
|
|
|
3454
3481
|
return branded;
|
|
3455
3482
|
}
|
|
3456
3483
|
/** `frontend/src/cms/index.ts`: the customizations in navigation order, and the external collections. */
|
|
3457
|
-
function printCmsIndex(cmsDir, customizations, external) {
|
|
3484
|
+
function printCmsIndex(cmsDir, customizations, external, style) {
|
|
3458
3485
|
const lines = [];
|
|
3459
|
-
const
|
|
3460
|
-
|
|
3461
|
-
return JSON.stringify(relative.startsWith(".") ? relative : `./${relative}`);
|
|
3462
|
-
};
|
|
3486
|
+
const indexFile = path.join(cmsDir, "index.ts");
|
|
3487
|
+
const specifier = (file) => JSON.stringify(generatedSpecifier(indexFile, file, style));
|
|
3463
3488
|
for (const module of customizations) lines.push(`import { ${module.identifier} } from ${specifier(module.file)};`);
|
|
3464
3489
|
for (const module of external) lines.push(`import ${module.identifier} from ${specifier(module.file)};`);
|
|
3465
3490
|
if (lines.length > 0) lines.push("");
|
|
@@ -8024,7 +8049,7 @@ function planFrontendWiring(plan, frontendDir, hasExternal) {
|
|
|
8024
8049
|
const mountsUiConfig = /\buiConfig\s*=/.test(appText);
|
|
8025
8050
|
if (!fs.existsSync(uiConfigFile) && !plan.files.has(uiConfigFile)) planFile(plan, uiConfigFile, UI_CONFIG_CONTENT, "ui-config.json (the collection editor's presentation file)");
|
|
8026
8051
|
const wireUiConfig = !mountsUiConfig;
|
|
8027
|
-
const importLine = `import { ${names} } from "./cms";${wireUiConfig ? `\n${UI_CONFIG_IMPORT}` : ""}`;
|
|
8052
|
+
const importLine = `import { ${names} } from "${plan.specifierStyle === "js" ? "./cms/index.js" : "./cms"}";${wireUiConfig ? `\n${UI_CONFIG_IMPORT}` : ""}`;
|
|
8028
8053
|
const props = [
|
|
8029
8054
|
"tableCustomizations={tableCustomizations}",
|
|
8030
8055
|
...hasExternal ? ["externalCollections={externalCollections}"] : [],
|
|
@@ -9076,16 +9101,6 @@ async function migrateWithShims(options, shimDir) {
|
|
|
9076
9101
|
backend: path.join(root, "backend", "lib"),
|
|
9077
9102
|
frontend: cmsDir ? path.join(cmsDir, "lib") : path.join(root, "frontend", "src", "cms", "lib")
|
|
9078
9103
|
});
|
|
9079
|
-
const plan = {
|
|
9080
|
-
root,
|
|
9081
|
-
ast,
|
|
9082
|
-
relocator,
|
|
9083
|
-
...frontendDir ? { frontendDir } : {},
|
|
9084
|
-
files: /* @__PURE__ */ new Map(),
|
|
9085
|
-
refusals: report.refusals,
|
|
9086
|
-
notes: report.notes,
|
|
9087
|
-
manualSteps: report.manualSteps
|
|
9088
|
-
};
|
|
9089
9104
|
const entries = legacy.collections.map(({ collection, file }) => {
|
|
9090
9105
|
const sourceFile = addSourceFile(ast, file, fs.readFileSync(file, "utf8"));
|
|
9091
9106
|
const site = findCollectionSite(ast, sourceFile);
|
|
@@ -9096,6 +9111,18 @@ async function migrateWithShims(options, shimDir) {
|
|
|
9096
9111
|
...site.node ? { site: site.node } : { siteProblem: site.reason }
|
|
9097
9112
|
};
|
|
9098
9113
|
});
|
|
9114
|
+
const legacyIndexFile = ["index.ts", "index.js"].map((file) => path.join(legacy.collectionsDir, file)).find((file) => fs.existsSync(file));
|
|
9115
|
+
const plan = {
|
|
9116
|
+
root,
|
|
9117
|
+
ast,
|
|
9118
|
+
relocator,
|
|
9119
|
+
specifierStyle: projectSpecifierStyle([...entries.flatMap((entry) => writtenSpecifiers(entry.sourceFile)), ...legacyIndexFile ? writtenSpecifiers(addSourceFile(ast, legacyIndexFile, fs.readFileSync(legacyIndexFile, "utf8"))) : []]),
|
|
9120
|
+
...frontendDir ? { frontendDir } : {},
|
|
9121
|
+
files: /* @__PURE__ */ new Map(),
|
|
9122
|
+
refusals: report.refusals,
|
|
9123
|
+
notes: report.notes,
|
|
9124
|
+
manualSteps: report.manualSteps
|
|
9125
|
+
};
|
|
9099
9126
|
for (const entry of entries) {
|
|
9100
9127
|
if (!entry.site?.binding) continue;
|
|
9101
9128
|
for (const [assigned, { statement }] of postDeclarationAssignments(ast, entry.sourceFile, entry.site.binding)) note(plan, entry, `\`${entry.site.binding}.${assigned}\` is assigned after the declaration; the evaluated value is what was carried.`, statement.getStartLineNumber());
|
|
@@ -9264,11 +9291,10 @@ async function migrateWithShims(options, shimDir) {
|
|
|
9264
9291
|
file: relativeToRoot(plan, legacy.collectionsDir)
|
|
9265
9292
|
});
|
|
9266
9293
|
if (cmsDir && frontendDir) {
|
|
9267
|
-
if (customizationModules.length > 0 || external.length > 0) planFile(plan, path.join(cmsDir, "index.ts"), printCmsIndex(cmsDir, customizationModules, external), "the CMS index");
|
|
9294
|
+
if (customizationModules.length > 0 || external.length > 0) planFile(plan, path.join(cmsDir, "index.ts"), printCmsIndex(cmsDir, customizationModules, external, plan.specifierStyle), "the CMS index");
|
|
9268
9295
|
planFrontendWiring(plan, frontendDir, external.length > 0);
|
|
9269
9296
|
}
|
|
9270
9297
|
planStaticAppGuards(plan, frontendDir);
|
|
9271
|
-
const legacyIndexFile = ["index.ts", "index.js"].map((file) => path.join(legacy.collectionsDir, file)).find((file) => fs.existsSync(file));
|
|
9272
9298
|
const schemaIndex = plan.files.get(path.join(schemaDir, "index.ts"));
|
|
9273
9299
|
if (legacyIndexFile && schemaIndex) {
|
|
9274
9300
|
const cmsIndexPath = cmsDir ? path.join(cmsDir, "index.ts") : void 0;
|
|
@@ -9981,4 +10007,4 @@ async function runSdkCalls(flags, dir, aliases) {
|
|
|
9981
10007
|
//#endregion
|
|
9982
10008
|
export { printCollectionsToTablesHelp, printSdkCallsHelp, runCollectionsToTables, runSdkCalls };
|
|
9983
10009
|
|
|
9984
|
-
//# sourceMappingURL=command-
|
|
10010
|
+
//# sourceMappingURL=command-D9g46gg9.js.map
|