@rebasepro/cli 0.30.0 → 0.31.0-canary.g59cd6fd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/dist/{agent-setup-0uyfC7VX.js → agent-setup-DqAcoDcn.js} +10 -5
- package/dist/{agent-setup-0uyfC7VX.js.map → agent-setup-DqAcoDcn.js.map} +1 -1
- package/dist/{api-keys-Dfw5-9s1.js → api-keys-eIUjMqWn.js} +8 -7
- package/dist/api-keys-eIUjMqWn.js.map +1 -0
- package/dist/{apps-MKQbgDtN.js → apps-DExO4PEl.js} +8 -7
- package/dist/apps-DExO4PEl.js.map +1 -0
- package/dist/{project-CasK56vN.js → args-CaCcrYE1.js} +2 -351
- package/dist/args-CaCcrYE1.js.map +1 -0
- package/dist/{atlas-dev-database-BODqdCWt.js → atlas-dev-database-DOCKk6ht.js} +2 -2
- package/dist/{atlas-dev-database-BODqdCWt.js.map → atlas-dev-database-DOCKk6ht.js.map} +1 -1
- package/dist/{auth-Bv0rTbQX.js → auth-D96QYgFR.js} +7 -6
- package/dist/{auth-Bv0rTbQX.js.map → auth-D96QYgFR.js.map} +1 -1
- package/dist/backend-guard-C0mVkXBw.js +162 -0
- package/dist/backend-guard-C0mVkXBw.js.map +1 -0
- package/dist/{branch-pointer-BQUF6lYa.js → branch-pointer-DMPyvZoK.js} +1 -1
- package/dist/{build-BuKTnec8.js → build-CA5R07tw.js} +29 -9
- package/dist/build-CA5R07tw.js.map +1 -0
- package/dist/{bundle-BAH4FCju.js → bundle-DgILeA5b.js} +112 -138
- package/dist/bundle-DgILeA5b.js.map +1 -0
- package/dist/bundle.d.ts +35 -12
- package/dist/cli.d.ts +2 -2
- package/dist/{cloud-Cj5ey3l_.js → cloud-CYMk92iG.js} +217 -104
- package/dist/cloud-CYMk92iG.js.map +1 -0
- package/dist/cms-directories-BK3vcswg.js +33 -0
- package/dist/cms-directories-BK3vcswg.js.map +1 -0
- package/dist/codemod/collections-to-tables/ast.d.ts +135 -0
- package/dist/codemod/collections-to-tables/backend.d.ts +38 -0
- package/dist/codemod/collections-to-tables/command.d.ts +35 -0
- package/dist/codemod/collections-to-tables/comments.d.ts +45 -0
- package/dist/codemod/collections-to-tables/customization.d.ts +47 -0
- package/dist/codemod/collections-to-tables/dynamic-props.d.ts +34 -0
- package/dist/codemod/collections-to-tables/export-changes.d.ts +83 -0
- package/dist/codemod/collections-to-tables/firestore.d.ts +11 -0
- package/dist/codemod/collections-to-tables/helper-hooks.d.ts +41 -0
- package/dist/codemod/collections-to-tables/hooks.d.ts +44 -0
- package/dist/codemod/collections-to-tables/journal.d.ts +10 -0
- package/dist/codemod/collections-to-tables/legacy-shims.d.ts +52 -0
- package/dist/codemod/collections-to-tables/load-legacy.d.ts +81 -0
- package/dist/codemod/collections-to-tables/migrate.d.ts +20 -0
- package/dist/codemod/collections-to-tables/modules.d.ts +127 -0
- package/dist/codemod/collections-to-tables/moved-imports.d.ts +70 -0
- package/dist/codemod/collections-to-tables/moved-symbols.generated.d.ts +12 -0
- package/dist/codemod/collections-to-tables/own.d.ts +10 -0
- package/dist/codemod/collections-to-tables/path-aliases.d.ts +26 -0
- package/dist/codemod/collections-to-tables/plan-context.d.ts +49 -0
- package/dist/codemod/collections-to-tables/print-js.d.ts +44 -0
- package/dist/codemod/collections-to-tables/project-files.d.ts +144 -0
- package/dist/codemod/collections-to-tables/repoint.d.ts +50 -0
- package/dist/codemod/collections-to-tables/row-hands.d.ts +7 -0
- package/dist/codemod/collections-to-tables/sdk-calls.d.ts +88 -0
- package/dist/codemod/collections-to-tables/skills-step.d.ts +13 -0
- package/dist/codemod/collections-to-tables/split-constants.d.ts +42 -0
- package/dist/codemod/collections-to-tables/storage-paths.d.ts +28 -0
- package/dist/codemod/collections-to-tables/types.d.ts +164 -0
- package/dist/codemod/collections-to-tables/verify.d.ts +27 -0
- package/dist/codemod/collections-to-tables/vocabulary.d.ts +40 -0
- package/dist/command-D5lhW_-B.js +9984 -0
- package/dist/command-D5lhW_-B.js.map +1 -0
- package/dist/commands/agent-setup.d.ts +6 -2
- package/dist/commands/cloud/auth.d.ts +2 -0
- package/dist/commands/cloud/context.d.ts +1 -1
- package/dist/commands/cloud/init.d.ts +2 -2
- package/dist/commands/cloud/login-flow.d.ts +30 -1
- package/dist/commands/console.d.ts +1 -2
- package/dist/commands/db.d.ts +5 -6
- package/dist/commands/dev.d.ts +18 -17
- package/dist/commands/doctor.d.ts +4 -5
- package/dist/commands/eject.d.ts +17 -13
- package/dist/commands/generate-view.d.ts +20 -9
- package/dist/commands/generate_sdk.d.ts +27 -27
- package/dist/commands/init.d.ts +21 -8
- package/dist/commands/migrate.d.ts +24 -0
- package/dist/commands/schema-reconcile.d.ts +1 -1
- package/dist/commands/skills.d.ts +8 -0
- package/dist/commands/verify-cms.d.ts +28 -0
- package/dist/commands/verify.d.ts +14 -9
- package/dist/{consent-BD7F29T3.js → consent-BXLIrMl8.js} +2 -2
- package/dist/{consent-BD7F29T3.js.map → consent-BXLIrMl8.js.map} +1 -1
- package/dist/{console-CdwIYOMV.js → console-C1d3LwB7.js} +14 -14
- package/dist/console-C1d3LwB7.js.map +1 -0
- package/dist/{context-AXdAh-q8.js → context--JwaHaZp.js} +6 -5
- package/dist/context--JwaHaZp.js.map +1 -0
- package/dist/{daemon-Cp7oNXth.js → daemon-w30PsdwV.js} +2 -2
- package/dist/{daemon-Cp7oNXth.js.map → daemon-w30PsdwV.js.map} +1 -1
- package/dist/{db-DBbKpjYX.js → db-DQZK9n9c.js} +52 -51
- package/dist/db-DQZK9n9c.js.map +1 -0
- package/dist/{derive-ae9UOoOB.js → derive-C3ezmY-p.js} +105 -133
- package/dist/derive-C3ezmY-p.js.map +1 -0
- package/dist/{dev-C93d4QIv.js → dev-PY5h4O6u.js} +142 -84
- package/dist/dev-PY5h4O6u.js.map +1 -0
- package/dist/dev-db/attver.d.ts +32 -0
- package/dist/dev-db/pull.d.ts +15 -1
- package/dist/{dev-preflight-Cxv3TiD1.js → dev-preflight-DjvcV6SK.js} +5 -5
- package/dist/dev-preflight-DjvcV6SK.js.map +1 -0
- package/dist/{dev-server-OJsUGZEB.js → dev-server-BLxCbQEP.js} +2 -2
- package/dist/{dev-server-OJsUGZEB.js.map → dev-server-BLxCbQEP.js.map} +1 -1
- package/dist/{doctor-BBPQUO2g.js → doctor-CnUu8kpM.js} +39 -62
- package/dist/doctor-CnUu8kpM.js.map +1 -0
- package/dist/doctor-environment.d.ts +6 -6
- package/dist/{eject-DABcDnPN.js → eject-Bhzd6hgb.js} +25 -16
- package/dist/eject-Bhzd6hgb.js.map +1 -0
- package/dist/{fold-static-BWzxNn06.js → fold-static-CKewnAPX.js} +5 -3
- package/dist/fold-static-CKewnAPX.js.map +1 -0
- package/dist/{generate-view-IFwCADvb.js → generate-view-CTOluXvH.js} +160 -89
- package/dist/generate-view-CTOluXvH.js.map +1 -0
- package/dist/{generate_sdk-DNmNuFuW.js → generate_sdk-De-aLC1L.js} +120 -137
- package/dist/generate_sdk-De-aLC1L.js.map +1 -0
- package/dist/import-schema-module-Df67TIWj.js +51 -0
- package/dist/import-schema-module-Df67TIWj.js.map +1 -0
- package/dist/index.es.js +64 -51
- package/dist/index.es.js.map +1 -1
- package/dist/{init-vL1DWOeC.js → init-Dtl-IcXf.js} +83 -80
- package/dist/init-Dtl-IcXf.js.map +1 -0
- package/dist/last-dev-database-Dc8cP01o.js +2 -0
- package/dist/{manifest-BtzDy7KQ.js → manifest-C3uLDrrJ.js} +115 -40
- package/dist/manifest-C3uLDrrJ.js.map +1 -0
- package/dist/manifest.d.ts +79 -24
- package/dist/migrate-VrKoi3nB.js +138 -0
- package/dist/migrate-VrKoi3nB.js.map +1 -0
- package/dist/{normalize-imports-Bd5Y4yLp.js → normalize-imports-DwxqEMYq.js} +3 -3
- package/dist/{normalize-imports-Bd5Y4yLp.js.map → normalize-imports-DwxqEMYq.js.map} +1 -1
- package/dist/path-flags-7O5uPBcQ.js +139 -0
- package/dist/path-flags-7O5uPBcQ.js.map +1 -0
- package/dist/{prepare-CTw9NEkh.js → prepare-Ccxspoj-.js} +4 -4
- package/dist/{prepare-CTw9NEkh.js.map → prepare-Ccxspoj-.js.map} +1 -1
- package/dist/project-CLcF5i8c.js +360 -0
- package/dist/project-CLcF5i8c.js.map +1 -0
- package/dist/project-schema-CsSOG2gE.js +30 -0
- package/dist/project-schema-CsSOG2gE.js.map +1 -0
- package/dist/{pull-DDMpsZ5r.js → pull-DRWqBZp5.js} +327 -4
- package/dist/pull-DRWqBZp5.js.map +1 -0
- package/dist/resolve-BY7bSFRT.js +2 -0
- package/dist/resources/derive.d.ts +19 -13
- package/dist/{resources-CPSC5Kcu.js → resources-Dpfs2y8P.js} +5 -4
- package/dist/{resources-CPSC5Kcu.js.map → resources-Dpfs2y8P.js.map} +1 -1
- package/dist/{schema-DtLPsXbT.js → schema-CdDjv5zI.js} +41 -39
- package/dist/schema-CdDjv5zI.js.map +1 -0
- package/dist/schema-dir-Cd1kvYbf.js +98 -0
- package/dist/schema-dir-Cd1kvYbf.js.map +1 -0
- package/dist/schema-reconcile-BAupXfkd.js +2 -0
- package/dist/schema-text-CpNrsuMe.js +73 -0
- package/dist/schema-text-CpNrsuMe.js.map +1 -0
- package/dist/{skills-CbwV6vw_.js → skills-CXjA9TWw.js} +54 -10
- package/dist/skills-CXjA9TWw.js.map +1 -0
- package/dist/{start-YOr3X5Zm.js → start-Bwbtt2W5.js} +7 -10
- package/dist/{start-YOr3X5Zm.js.map → start-Bwbtt2W5.js.map} +1 -1
- package/dist/{status-BREvtzJm.js → status-D7XCGHu2.js} +12 -12
- package/dist/status-D7XCGHu2.js.map +1 -0
- package/dist/{storage-CO9ouK76.js → storage-iTqj5-Av.js} +12 -11
- package/dist/storage-iTqj5-Av.js.map +1 -0
- package/dist/{telemetry-DwK5RQJl.js → telemetry-BP_1Cl9r.js} +4 -4
- package/dist/{telemetry-DwK5RQJl.js.map → telemetry-BP_1Cl9r.js.map} +1 -1
- package/dist/{telemetry-CgwJPVMO.js → telemetry-M3HjlyhZ.js} +2 -2
- package/dist/{telemetry-CgwJPVMO.js.map → telemetry-M3HjlyhZ.js.map} +1 -1
- package/dist/{upgrade-B7sVwL8S.js → upgrade-oZzJ13jM.js} +5 -4
- package/dist/{upgrade-B7sVwL8S.js.map → upgrade-oZzJ13jM.js.map} +1 -1
- package/dist/utils/backend-guard.d.ts +47 -0
- package/dist/utils/cms-directories.d.ts +6 -0
- package/dist/utils/dev-preflight.d.ts +2 -2
- package/dist/utils/import-schema-module.d.ts +16 -0
- package/dist/utils/path-flags.d.ts +35 -16
- package/dist/utils/project-schema.d.ts +40 -0
- package/dist/utils/project.d.ts +8 -2
- package/dist/utils/schema-dir.d.ts +32 -0
- package/dist/utils/schema-drift.d.ts +6 -0
- package/dist/utils/schema-text.d.ts +24 -0
- package/dist/verify-5p_vaUG2.js +1160 -0
- package/dist/verify-5p_vaUG2.js.map +1 -0
- package/package.json +11 -8
- package/runtime/dev-server.mjs +5 -1
- package/templates/eject/Dockerfile +1 -4
- package/templates/eject/backend/src/env.ts +1 -1
- package/templates/eject/backend/src/index.ts +53 -40
- package/templates/eject/docker-compose.custom.yml +1 -1
- package/templates/overlays/baas/README.md +39 -12
- package/templates/overlays/baas/ai-instructions.md +8 -8
- package/templates/overlays/baas/{config → backend}/storage.ts +3 -4
- package/templates/overlays/baas/backend/tsconfig.json +10 -12
- package/templates/overlays/baas/package.json +1 -2
- package/templates/overlays/baas/pnpm-workspace.yaml +0 -1
- package/templates/presets/blank/backend/schema/index.ts +19 -0
- package/templates/presets/blank/frontend/src/App.tsx +56 -0
- package/templates/presets/ecommerce/backend/schema/categories.ts +12 -0
- package/templates/presets/ecommerce/backend/schema/index.ts +23 -0
- package/templates/presets/ecommerce/backend/schema/orders.ts +13 -0
- package/templates/presets/ecommerce/backend/schema/products.ts +18 -0
- package/templates/presets/ecommerce/frontend/src/App.tsx +59 -0
- package/templates/presets/ecommerce/frontend/src/cms/categories.tsx +12 -0
- package/templates/presets/ecommerce/frontend/src/cms/orders.tsx +38 -0
- package/templates/presets/ecommerce/frontend/src/cms/products.tsx +27 -0
- package/templates/resource-graphs/blank.json +2 -2
- package/templates/resource-graphs/blog.json +5 -5
- package/templates/resource-graphs/ecommerce.json +5 -5
- package/templates/resource-graphs/headless.json +1 -1
- package/templates/template/.claude/hooks/post-edit-collection.sh +27 -23
- package/templates/template/.cursorrules +2 -2
- package/templates/template/.env.example +6 -17
- package/templates/template/.github/copilot-instructions.md +2 -2
- package/templates/template/.windsurfrules +2 -2
- package/templates/template/AGENTS.md +2 -2
- package/templates/template/CLAUDE.md +2 -2
- package/templates/template/README.md +47 -13
- package/templates/template/ai-instructions.md +15 -14
- package/templates/template/backend/functions/hello.ts +1 -1
- package/templates/template/backend/package.json +0 -2
- package/templates/template/{config → backend}/resources.ts +3 -3
- package/templates/template/backend/schema/authors.ts +11 -0
- package/templates/template/backend/schema/index.ts +29 -0
- package/templates/template/backend/schema/posts.ts +29 -0
- package/templates/template/backend/schema/tags.ts +9 -0
- package/templates/template/backend/schema/users.ts +32 -0
- package/templates/template/{config → backend}/storage.ts +4 -4
- package/templates/template/backend/tsconfig.json +15 -20
- package/templates/template/docker-compose.yml +3 -3
- package/templates/template/frontend/package.json +0 -2
- package/templates/template/frontend/src/App.tsx +10 -4
- package/templates/template/frontend/src/cms/authors.tsx +7 -0
- package/templates/template/frontend/src/cms/posts.tsx +27 -0
- package/templates/template/frontend/src/cms/tags.tsx +11 -0
- package/templates/template/frontend/src/cms/ui-config.json +3 -0
- package/templates/template/frontend/src/cms/users.tsx +54 -0
- package/templates/template/frontend/src/{virtual.d.ts → vite-env.d.ts} +0 -4
- package/templates/template/frontend/vite.config.ts +6 -2
- package/templates/template/gitignore +1 -1
- package/templates/template/package.json +1 -2
- package/templates/template/pnpm-workspace.yaml +0 -1
- package/templates/template/scripts/example.ts +3 -3
- package/templates/template/tsconfig.json +1 -1
- package/templates/views/AppView.tsx.tmpl +4 -4
- package/templates/views/EntityView.tsx.tmpl +3 -4
- package/dist/api-keys-Dfw5-9s1.js.map +0 -1
- package/dist/apps-MKQbgDtN.js.map +0 -1
- package/dist/build-BuKTnec8.js.map +0 -1
- package/dist/bundle-BAH4FCju.js.map +0 -1
- package/dist/cloud-Cj5ey3l_.js.map +0 -1
- package/dist/collection-drift-BKj_BoMq.js +0 -106
- package/dist/collection-drift-BKj_BoMq.js.map +0 -1
- package/dist/collections-dir-DlvDhime.js +0 -69
- package/dist/collections-dir-DlvDhime.js.map +0 -1
- package/dist/console-CdwIYOMV.js.map +0 -1
- package/dist/context-AXdAh-q8.js.map +0 -1
- package/dist/db-DBbKpjYX.js.map +0 -1
- package/dist/derive-ae9UOoOB.js.map +0 -1
- package/dist/dev-C93d4QIv.js.map +0 -1
- package/dist/dev-preflight-Cxv3TiD1.js.map +0 -1
- package/dist/doctor-BBPQUO2g.js.map +0 -1
- package/dist/eject-DABcDnPN.js.map +0 -1
- package/dist/fold-static-BWzxNn06.js.map +0 -1
- package/dist/generate-view-IFwCADvb.js.map +0 -1
- package/dist/generate_sdk-DNmNuFuW.js.map +0 -1
- package/dist/init-vL1DWOeC.js.map +0 -1
- package/dist/last-dev-database-DpW5dfoX.js +0 -2
- package/dist/manifest-BtzDy7KQ.js.map +0 -1
- package/dist/path-flags-DNvtEi2-.js +0 -92
- package/dist/path-flags-DNvtEi2-.js.map +0 -1
- package/dist/project-CasK56vN.js.map +0 -1
- package/dist/pull-DDMpsZ5r.js.map +0 -1
- package/dist/resolve-D647F1LA.js +0 -2
- package/dist/schema-DtLPsXbT.js.map +0 -1
- package/dist/schema-reconcile-DkArN9jF.js +0 -2
- package/dist/skills-CbwV6vw_.js.map +0 -1
- package/dist/status-BREvtzJm.js.map +0 -1
- package/dist/storage-CO9ouK76.js.map +0 -1
- package/dist/utils/collection-drift.d.ts +0 -27
- package/dist/utils/collections-dir.d.ts +0 -14
- package/dist/verify-Y3rWSgfA.js +0 -730
- package/dist/verify-Y3rWSgfA.js.map +0 -1
- package/templates/overlays/baas/config/index.ts +0 -24
- package/templates/overlays/baas/config/package.json +0 -30
- package/templates/template/config/cms.d.ts +0 -15
- package/templates/template/config/collections/authors.ts +0 -47
- package/templates/template/config/collections/index.ts +0 -44
- package/templates/template/config/collections/posts.ts +0 -94
- package/templates/template/config/collections/presets/blank/index.ts +0 -5
- package/templates/template/config/collections/presets/ecommerce/categories.ts +0 -42
- package/templates/template/config/collections/presets/ecommerce/index.ts +0 -31
- package/templates/template/config/collections/presets/ecommerce/orders.ts +0 -78
- package/templates/template/config/collections/presets/ecommerce/products.ts +0 -73
- package/templates/template/config/collections/tags.ts +0 -27
- package/templates/template/config/collections/users.ts +0 -149
- package/templates/template/config/frontend-assets.d.ts +0 -17
- package/templates/template/config/index.ts +0 -12
- package/templates/template/config/package.json +0 -30
- package/templates/template/config/tsconfig.json +0 -35
- /package/templates/eject/{config → backend}/resources.ts +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { SchemaModuleImporter } from "@rebasepro/server";
|
|
2
|
+
import { type LegacyCollectionConfig } from "@rebasepro/common/migrate";
|
|
3
|
+
import { type SecurityRule } from "@rebasepro/types";
|
|
4
|
+
/** A legacy collection, with the file it came from. */
|
|
5
|
+
export interface LoadedCollection {
|
|
6
|
+
collection: LegacyCollectionConfig;
|
|
7
|
+
/** The file, absolute. */
|
|
8
|
+
file: string;
|
|
9
|
+
}
|
|
10
|
+
/** A legacy project, evaluated. */
|
|
11
|
+
export interface LegacyProject {
|
|
12
|
+
/** The config directory (`config/`), absolute. */
|
|
13
|
+
configDir: string;
|
|
14
|
+
/** `<config>/collections`, absolute. */
|
|
15
|
+
collectionsDir: string;
|
|
16
|
+
/** Every collection, in the loader's order (file name order). */
|
|
17
|
+
collections: LoadedCollection[];
|
|
18
|
+
/** The index's `defaultSecurityRules`, when it exports any. */
|
|
19
|
+
defaultSecurityRules?: SecurityRule[];
|
|
20
|
+
/** The index's `collections` array, when it exports one: the panel's navigation order. */
|
|
21
|
+
navigationOrder?: LegacyCollectionConfig[];
|
|
22
|
+
/** Named exports of `<config>/index.ts`, when there is one (to find `callbacks`, `storageAuthorize`). */
|
|
23
|
+
configIndexExports: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Files of `<config>/collections` that export no collection at all — no
|
|
26
|
+
* default export, and no named export shaped like one: helpers the
|
|
27
|
+
* collection files import (`_predicates.ts`), absolute. A project that passed
|
|
28
|
+
* its collections as an array never had its directory read, so these were
|
|
29
|
+
* never collections; they are moved like any other module of `config/`.
|
|
30
|
+
*/
|
|
31
|
+
helperFiles: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Firestore collections the project builds in a module the loader never
|
|
34
|
+
* read: a file under a subdirectory of `<config>/collections`, or a function
|
|
35
|
+
* the index exports (`getAllFirestoreCollections()`), which the app spread
|
|
36
|
+
* into the panel's collections. Empty when there are none.
|
|
37
|
+
*/
|
|
38
|
+
builtFirestore: BuiltFirestoreCollection[];
|
|
39
|
+
/** The zero-argument functions that returned Firestore collections, with what each returned. */
|
|
40
|
+
firestoreBuilders: FirestoreBuilder[];
|
|
41
|
+
}
|
|
42
|
+
/** A Firestore collection reached outside the loader's top-level files. */
|
|
43
|
+
export interface BuiltFirestoreCollection {
|
|
44
|
+
collection: LegacyCollectionConfig;
|
|
45
|
+
/**
|
|
46
|
+
* The module whose default export is this collection's object (or one with
|
|
47
|
+
* its slug), absolute — absent when the collection only exists as what a
|
|
48
|
+
* call returns (built per locale, say), so no literal of its own exists.
|
|
49
|
+
*/
|
|
50
|
+
file?: string;
|
|
51
|
+
}
|
|
52
|
+
/** An exported zero-argument function that returned Firestore collections. */
|
|
53
|
+
export interface FirestoreBuilder {
|
|
54
|
+
/** The module that exports it, absolute. */
|
|
55
|
+
file: string;
|
|
56
|
+
/** Its export name. */
|
|
57
|
+
exportName: string;
|
|
58
|
+
/** The slugs it returned, in order. */
|
|
59
|
+
slugs: string[];
|
|
60
|
+
/**
|
|
61
|
+
* The slugs it returned as a different object than their file exports — a
|
|
62
|
+
* copy the builder changed at run time (added a field, say), which a
|
|
63
|
+
* conversion of the file alone does not carry.
|
|
64
|
+
*/
|
|
65
|
+
changed: string[];
|
|
66
|
+
}
|
|
67
|
+
/** A module importer: the CLI's jiti importer (`createSchemaModuleImporter`), or a stand-in in tests. */
|
|
68
|
+
export type ModuleImporter = SchemaModuleImporter;
|
|
69
|
+
/** The loader's file filter (`isCollectionFile` in `@rebasepro/server`). */
|
|
70
|
+
export declare function isLegacyCollectionFile(file: string): boolean;
|
|
71
|
+
/** Thrown when the legacy project cannot be evaluated: its own loader would refuse it too. */
|
|
72
|
+
export declare class LegacyLoadError extends Error {
|
|
73
|
+
readonly file?: string | undefined;
|
|
74
|
+
constructor(message: string, file?: string | undefined);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Evaluate `<config>/collections` of a project.
|
|
78
|
+
*
|
|
79
|
+
* @param configDir the config directory, absolute
|
|
80
|
+
*/
|
|
81
|
+
export declare function loadLegacyProject(configDir: string, importModule: ModuleImporter): Promise<LegacyProject>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { MigrateOptions, MigrationReport } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Whether the project's git tree is clean, or why it is not usable as a safety net.
|
|
4
|
+
*
|
|
5
|
+
* @param root the project root
|
|
6
|
+
*/
|
|
7
|
+
export declare function gitState(root: string): {
|
|
8
|
+
clean: true;
|
|
9
|
+
} | {
|
|
10
|
+
clean: false;
|
|
11
|
+
reason: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Run the codemod on one project.
|
|
15
|
+
*
|
|
16
|
+
* The shims the legacy `config/` is loaded with are written into a directory
|
|
17
|
+
* of this run's own, deleted when the run is over — whether it succeeded,
|
|
18
|
+
* refused or threw (see `ShimDir`).
|
|
19
|
+
*/
|
|
20
|
+
export declare function migrateCollectionsToTables(options: MigrateOptions): Promise<MigrationReport>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { AstContext, ImportUse } from "./ast.js";
|
|
2
|
+
/** Which side of the split a file lives on. */
|
|
3
|
+
export type Side = "backend" | "frontend";
|
|
4
|
+
/** A module specifier that cannot be moved, and why. */
|
|
5
|
+
export declare class RelocationError extends Error {
|
|
6
|
+
readonly file: string;
|
|
7
|
+
constructor(file: string, message: string);
|
|
8
|
+
}
|
|
9
|
+
/** How a relative specifier was written, so the moved one is written the same way. */
|
|
10
|
+
export type SpecifierStyle = "extensionless" | "directory" | {
|
|
11
|
+
extension: string;
|
|
12
|
+
};
|
|
13
|
+
export interface ResolvedSpecifier {
|
|
14
|
+
target: string;
|
|
15
|
+
style: SpecifierStyle;
|
|
16
|
+
}
|
|
17
|
+
/** The file a relative specifier written in `fromFile` names, and how it was written. */
|
|
18
|
+
export declare function resolveRelative(fromFile: string, specifier: string): ResolvedSpecifier;
|
|
19
|
+
/** A relative specifier from `fromFile` to `target`, written in `style`. */
|
|
20
|
+
export declare function writeSpecifier(fromFile: string, target: string, style: SpecifierStyle): string;
|
|
21
|
+
/** One helper module copied out of `config/`. */
|
|
22
|
+
export interface HelperCopy {
|
|
23
|
+
/** Where it was, absolute. */
|
|
24
|
+
from: string;
|
|
25
|
+
/** Where it goes, absolute. */
|
|
26
|
+
to: string;
|
|
27
|
+
side: Side;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Moves specifiers and collects the helper copies they need. One per run, so
|
|
31
|
+
* a helper used by several files is copied once per side.
|
|
32
|
+
*/
|
|
33
|
+
export declare class Relocator {
|
|
34
|
+
private readonly ctx;
|
|
35
|
+
private readonly projectRoot;
|
|
36
|
+
private readonly configDir;
|
|
37
|
+
private readonly collectionFiles;
|
|
38
|
+
private readonly libDirs;
|
|
39
|
+
readonly helpers: Map<string, HelperCopy>;
|
|
40
|
+
/** Modules of the project's own in config/ that backend code the run writes imports in place. */
|
|
41
|
+
readonly keptBackendModules: Set<string>;
|
|
42
|
+
/** Modules outside config/collections the run edits in place for the panel (a shared `dynamicProps` builder). */
|
|
43
|
+
readonly keptFrontendModules: Set<string>;
|
|
44
|
+
/** Edits to a module's own text before it is copied or kept (a helper's callbacks as table hooks), by absolute path. */
|
|
45
|
+
readonly sourceEdits: Map<string, {
|
|
46
|
+
start: number;
|
|
47
|
+
end: number;
|
|
48
|
+
text: string;
|
|
49
|
+
}[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Queue edits to a module's own text (deduplicated by position), dropping
|
|
52
|
+
* any copy of it already made so the next one carries them.
|
|
53
|
+
*/
|
|
54
|
+
addSourceEdits(file: string, edits: readonly {
|
|
55
|
+
start: number;
|
|
56
|
+
end: number;
|
|
57
|
+
text: string;
|
|
58
|
+
}[]): void;
|
|
59
|
+
/** A module's text with its {@link sourceEdits} applied. */
|
|
60
|
+
editedSource(file: string): string;
|
|
61
|
+
/** Collection files that move rather than become tables (Firestore ones): legacy path → new path. */
|
|
62
|
+
readonly moved: Map<string, string>;
|
|
63
|
+
constructor(ctx: AstContext, projectRoot: string, configDir: string, collectionFiles: ReadonlySet<string>, libDirs: Readonly<Record<Side, string>>);
|
|
64
|
+
/** The config directory, absolute. */
|
|
65
|
+
get configDirectory(): string;
|
|
66
|
+
/** Whether `file` is inside `<config>/collections`, which the migration removes. */
|
|
67
|
+
isInCollections(file: string): boolean;
|
|
68
|
+
/** Whether `file` is inside the config directory. */
|
|
69
|
+
isInConfig(file: string): boolean;
|
|
70
|
+
/** The specifier `specifier` (written in `fromFile`) becomes when written in `destFile`. */
|
|
71
|
+
relocate(specifier: string, fromFile: string, destFile: string, side: Side): string;
|
|
72
|
+
private copyHelper;
|
|
73
|
+
private readonly contents;
|
|
74
|
+
/** A helper's content in its new home: its relative specifiers moved. */
|
|
75
|
+
helperContent(copy: HelperCopy): string;
|
|
76
|
+
/**
|
|
77
|
+
* A module of config/ that backend code imports in place, with the
|
|
78
|
+
* collection-model types it imports replaced by table-model aliases (as a
|
|
79
|
+
* copy to backend/lib gets them): the hooks it serves are table hooks now.
|
|
80
|
+
*/
|
|
81
|
+
keptBackendContent(file: string): string;
|
|
82
|
+
/** Collection-model types left in moved backend code (used with type arguments), for the report. */
|
|
83
|
+
readonly legacyTypesLeft: {
|
|
84
|
+
file: string;
|
|
85
|
+
name: string;
|
|
86
|
+
}[];
|
|
87
|
+
/** Edits replacing the collection-model types a moved backend module imports (see {@link replaceLegacyTypes}). */
|
|
88
|
+
private legacyTypeEdits;
|
|
89
|
+
/**
|
|
90
|
+
* Every module specifier in `text` (static imports, re-exports, dynamic
|
|
91
|
+
* `import()`), moved from `fromFile` to `destFile`.
|
|
92
|
+
*/
|
|
93
|
+
moveSpecifiersInText(text: string, fromFile: string, destFile: string, side: Side): string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Collection-model types a backend helper used, and what each is in the table
|
|
97
|
+
* model (from `@rebasepro/server/schema`, which a backend depends on). A
|
|
98
|
+
* helper keeps its own name for the type — `type EntityCallbackContext =
|
|
99
|
+
* TableHookProps["context"];` — so its body is untouched.
|
|
100
|
+
*/
|
|
101
|
+
export declare const LEGACY_TYPE_REPLACEMENTS: Readonly<Record<string, {
|
|
102
|
+
type: string;
|
|
103
|
+
expression: string;
|
|
104
|
+
}>>;
|
|
105
|
+
/** What {@link replaceLegacyTypes} decided. */
|
|
106
|
+
export interface LegacyTypeReplacement {
|
|
107
|
+
/** The uses still imported as they were. */
|
|
108
|
+
kept: ImportUse[];
|
|
109
|
+
/** `import type { … } from "@rebasepro/server/schema";`, when any type was replaced. */
|
|
110
|
+
imports: string[];
|
|
111
|
+
/** `type <local> = <replacement>;`, one per replaced binding. */
|
|
112
|
+
aliases: string[];
|
|
113
|
+
/** A binding used with type arguments, which an alias cannot stand for. */
|
|
114
|
+
unreplaceable: string[];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Replace collection-model types a backend module imports with their
|
|
118
|
+
* table-model equivalents, as local aliases.
|
|
119
|
+
*
|
|
120
|
+
* @param text the code that uses them, to tell a generic use (`AfterSaveProps<M>`) apart
|
|
121
|
+
*/
|
|
122
|
+
export declare function replaceLegacyTypes(uses: readonly ImportUse[], text: string): LegacyTypeReplacement;
|
|
123
|
+
/**
|
|
124
|
+
* The import block of a generated module: the uses, grouped by (moved)
|
|
125
|
+
* specifier, in first-use order, each binding once.
|
|
126
|
+
*/
|
|
127
|
+
export declare function importLines(uses: readonly ImportUse[], relocate: (use: ImportUse) => string): string[];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { SourceFile } from "ts-morph";
|
|
2
|
+
import type { AstContext } from "./ast.js";
|
|
3
|
+
import type { ManualStep, MovedSymbol, Note } from "./types.js";
|
|
4
|
+
/** A replacement of `[start, end)` in a file's text. */
|
|
5
|
+
export interface TextEdit {
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
text: string;
|
|
9
|
+
}
|
|
10
|
+
/** One name an import or re-export of the file now takes from another package or under another name. */
|
|
11
|
+
export interface MovedName {
|
|
12
|
+
symbol: string;
|
|
13
|
+
from: string;
|
|
14
|
+
to: string;
|
|
15
|
+
as?: string;
|
|
16
|
+
}
|
|
17
|
+
/** What the pass found in one file. */
|
|
18
|
+
export interface MovedImportsResult {
|
|
19
|
+
edits: TextEdit[];
|
|
20
|
+
moved: MovedName[];
|
|
21
|
+
manualSteps: ManualStep[];
|
|
22
|
+
}
|
|
23
|
+
/** The row for a name imported from a module, if it moved or changed. */
|
|
24
|
+
export declare function movedSymbol(from: string, symbol: string): MovedSymbol | undefined;
|
|
25
|
+
/** Every row of the table (generated rows win), for the report and the tests. */
|
|
26
|
+
export declare function movedSymbolTable(): readonly MovedSymbol[];
|
|
27
|
+
/** The package a module specifier belongs to (`@rebasepro/common/migrate` → `@rebasepro/common`). */
|
|
28
|
+
export declare function packageOf(specifier: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Plan the moves of one file.
|
|
31
|
+
*
|
|
32
|
+
* @param ctx the AST context
|
|
33
|
+
* @param sf the file, parsed (syntax only)
|
|
34
|
+
* @param relative its path from the project root, for the steps
|
|
35
|
+
*/
|
|
36
|
+
export declare function rewriteMovedImports(ctx: AstContext, sf: SourceFile, relative: string): MovedImportsResult;
|
|
37
|
+
/** Whether a file can hold anything this pass reads (so the rest are never parsed). */
|
|
38
|
+
export declare function mayNeedImportPass(text: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The spellings of a source file whose meaning changed (never rewritten):
|
|
41
|
+
* {@link CODE_SPELLINGS}, and the call options of {@link CALL_OPTION_CHANGES}.
|
|
42
|
+
*/
|
|
43
|
+
export declare function detectChangedSpellings(ctx: AstContext, sf: SourceFile, relative: string): ManualStep[];
|
|
44
|
+
/** A dependency the run added to a workspace package. */
|
|
45
|
+
export interface AddedDependency {
|
|
46
|
+
/** The `package.json`, relative to the project root. */
|
|
47
|
+
file: string;
|
|
48
|
+
name: string;
|
|
49
|
+
version: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Add each package a moved import now names to the workspace package that
|
|
53
|
+
* imports it, when that package does not depend on it yet: in `dependencies`,
|
|
54
|
+
* with the range it gives its other `@rebasepro/*` packages (or the root's).
|
|
55
|
+
* A package with no such range to copy is a manual step.
|
|
56
|
+
*
|
|
57
|
+
* @param root the project root
|
|
58
|
+
* @param needed source file → the packages its imports now name
|
|
59
|
+
* @param read a file's current text (the migration's planned content first)
|
|
60
|
+
*/
|
|
61
|
+
export declare function planDependencies(root: string, needed: ReadonlyMap<string, ReadonlySet<string>>, read: (file: string) => string | undefined,
|
|
62
|
+
/** Versions to use for packages the config package declared (carried code moved out of config/). */
|
|
63
|
+
configVersions?: ReadonlyMap<string, string>): {
|
|
64
|
+
files: Map<string, string>;
|
|
65
|
+
added: AddedDependency[];
|
|
66
|
+
manualSteps: ManualStep[];
|
|
67
|
+
notes: Note[];
|
|
68
|
+
};
|
|
69
|
+
/** The old CLI spellings in a `package.json`'s scripts: a manual step, never rewritten. */
|
|
70
|
+
export declare function detectScriptSpellings(manifestText: string, relative: string): ManualStep[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GENERATED by tooling/scripts/codemod/moved-symbols-table.mjs from
|
|
3
|
+
* tooling/scripts/headless-guard/moved-symbols.json and
|
|
4
|
+
* tooling/scripts/headless-guard/cms-only-symbols.json — do not edit by hand: change
|
|
5
|
+
* the JSON and run the script again. `moved-imports.test.ts` fails while they disagree.
|
|
6
|
+
*
|
|
7
|
+
* Every symbol that left a package's root in 0.31: `to` is the package to import it from now
|
|
8
|
+
* (`as`: under that name), or null when it is gone and `instead` says what to write.
|
|
9
|
+
*/
|
|
10
|
+
import type { MovedSymbol } from "./types.js";
|
|
11
|
+
/** The symbols that moved or were removed, by the package they left. */
|
|
12
|
+
export declare const MOVED_SYMBOLS: readonly MovedSymbol[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A record's own entry, never one inherited from `Object.prototype`.
|
|
3
|
+
*
|
|
4
|
+
* The codemod looks keys up by names it read from user code, and a name can be
|
|
5
|
+
* `toString` or `constructor`: `RECORD[name]` would hand back a function.
|
|
6
|
+
*
|
|
7
|
+
* @param record a plain record
|
|
8
|
+
* @param key the key, as read
|
|
9
|
+
*/
|
|
10
|
+
export declare function own<T>(record: Readonly<Record<string, T>>, key: string): T | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** One alias: `prefix` (with its trailing `/` for a wildcard) → an absolute path. */
|
|
2
|
+
export interface PathAlias {
|
|
3
|
+
/** What a specifier starts with: `@config/` for `@config/*`, `@config` for a Vite alias, the whole key for an exact entry. */
|
|
4
|
+
prefix: string;
|
|
5
|
+
/** Whether the rest of the specifier is appended to `target` (`@config/*`, or a Vite alias). */
|
|
6
|
+
wildcard: boolean;
|
|
7
|
+
/** Exact (non-wildcard) Vite aliases also match `prefix/…`. */
|
|
8
|
+
vite: boolean;
|
|
9
|
+
/** The directory (wildcard) or module (exact) it names, absolute. */
|
|
10
|
+
target: string;
|
|
11
|
+
/** The directory whose files the alias applies to (the tsconfig's or Vite config's), absolute. */
|
|
12
|
+
scope: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Every alias the project's tsconfig files (`compilerOptions.paths`) and Vite
|
|
16
|
+
* configs (`resolve.alias` written as `path.resolve(__dirname, …)`) declare,
|
|
17
|
+
* in the project root and the directories below it. A tsconfig that extends
|
|
18
|
+
* another is read as written: its own `paths` only.
|
|
19
|
+
*/
|
|
20
|
+
export declare function readPathAliases(root: string): PathAlias[];
|
|
21
|
+
/**
|
|
22
|
+
* The relative specifier an aliased one stands for, from `fromFile` — or
|
|
23
|
+
* undefined when no alias in scope matches it. Longer prefixes win, as both
|
|
24
|
+
* TypeScript and Vite match the most specific entry.
|
|
25
|
+
*/
|
|
26
|
+
export declare function aliasToRelative(aliases: readonly PathAlias[], fromFile: string, specifier: string): string | undefined;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { SourceFile } from "ts-morph";
|
|
2
|
+
import type { LegacyCollectionConfig } from "@rebasepro/common/migrate";
|
|
3
|
+
import type { AstContext, CollectionSite } from "./ast.js";
|
|
4
|
+
import type { Relocator } from "./modules.js";
|
|
5
|
+
import type { SplitConstant } from "./split-constants.js";
|
|
6
|
+
import type { ManualStep, Note, Refusal } from "./types.js";
|
|
7
|
+
/** One legacy collection with everything the planners read about it. */
|
|
8
|
+
export interface CollectionEntry {
|
|
9
|
+
collection: LegacyCollectionConfig;
|
|
10
|
+
/** The collection file, absolute. */
|
|
11
|
+
file: string;
|
|
12
|
+
/** Its AST. */
|
|
13
|
+
sourceFile: SourceFile;
|
|
14
|
+
/** Where its literal is, when the codemod could find it. */
|
|
15
|
+
site?: CollectionSite;
|
|
16
|
+
/** Why the literal could not be found, when it could not. */
|
|
17
|
+
siteProblem?: string;
|
|
18
|
+
}
|
|
19
|
+
/** The shared state of one planning run. */
|
|
20
|
+
export interface PlanContext {
|
|
21
|
+
/** The project root, absolute. */
|
|
22
|
+
root: string;
|
|
23
|
+
ast: AstContext;
|
|
24
|
+
relocator: Relocator;
|
|
25
|
+
/** The frontend app's root directory, absolute, when the project has one. */
|
|
26
|
+
frontendDir?: string;
|
|
27
|
+
/** Planned files: absolute path → content. */
|
|
28
|
+
files: Map<string, {
|
|
29
|
+
content: string;
|
|
30
|
+
role: string;
|
|
31
|
+
}>;
|
|
32
|
+
refusals: Refusal[];
|
|
33
|
+
notes: Note[];
|
|
34
|
+
manualSteps: ManualStep[];
|
|
35
|
+
/** Enum constants of `config/` split into backend values and CMS labels (see `split-constants.ts`). */
|
|
36
|
+
splitConstants?: SplitConstant[];
|
|
37
|
+
}
|
|
38
|
+
/** A path relative to the project root, `/`-separated. */
|
|
39
|
+
export declare function relativeToRoot(plan: PlanContext, file: string): string;
|
|
40
|
+
/** Record a refusal about one collection. */
|
|
41
|
+
export declare function refuse(plan: PlanContext, entry: CollectionEntry | undefined, reason: string, extra?: {
|
|
42
|
+
key?: string;
|
|
43
|
+
line?: number;
|
|
44
|
+
file?: string;
|
|
45
|
+
}): void;
|
|
46
|
+
/** Record a note about one collection. */
|
|
47
|
+
export declare function note(plan: PlanContext, entry: CollectionEntry | undefined, message: string, line?: number): void;
|
|
48
|
+
/** Plan a file, refusing a second, different content for the same path. */
|
|
49
|
+
export declare function planFile(plan: PlanContext, file: string, content: string, role: string): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Printing plain values as TypeScript source, with code spliced in.
|
|
3
|
+
*
|
|
4
|
+
* The codemod writes two kinds of value: data it read off an evaluated
|
|
5
|
+
* collection (strings, numbers, arrays, objects), printed here, and code it
|
|
6
|
+
* read off the legacy source (a hook, an entity action, a component), carried
|
|
7
|
+
* as {@link RawSource} and printed verbatim, re-indented to where it lands.
|
|
8
|
+
*
|
|
9
|
+
* Same conventions as the shared table printer: four-space indentation,
|
|
10
|
+
* double quotes, no trailing commas, one entry per line for a non-empty
|
|
11
|
+
* object.
|
|
12
|
+
*/
|
|
13
|
+
/** Source text printed verbatim. Its first line starts at column 0; later lines carry their indentation relative to it. */
|
|
14
|
+
export declare class RawSource {
|
|
15
|
+
readonly text: string;
|
|
16
|
+
constructor(text: string);
|
|
17
|
+
}
|
|
18
|
+
/** An object key as written: bare when it is an identifier, quoted otherwise. */
|
|
19
|
+
export declare function printKey(key: string): string;
|
|
20
|
+
/** A string literal, double-quoted. */
|
|
21
|
+
export declare function printStringLiteral(value: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Re-indent raw source to land at `indent`: every line after the first gets
|
|
24
|
+
* the prefix, so the block keeps its own shape.
|
|
25
|
+
*/
|
|
26
|
+
export declare function reindent(text: string, indent: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Strip the indentation a node had in its file: `text` is the node's text
|
|
29
|
+
* (its first line starts at the node), `baseIndent` the leading whitespace of
|
|
30
|
+
* the line it starts on. Later lines that start with that whitespace lose it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function dedent(text: string, baseIndent: string): string;
|
|
33
|
+
/** Thrown for a value that is code, and that no source text was found for. */
|
|
34
|
+
export declare class UnprintableValueError extends Error {
|
|
35
|
+
readonly path: string;
|
|
36
|
+
constructor(path: string, message: string);
|
|
37
|
+
}
|
|
38
|
+
/** Whether a value holds a function anywhere: it then needs source text to print. */
|
|
39
|
+
export declare function containsCode(value: unknown, seen?: Set<unknown>): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* A value as source text, starting at `indent` (the indentation of the line
|
|
42
|
+
* it begins on).
|
|
43
|
+
*/
|
|
44
|
+
export declare function printValue(value: unknown, indent?: string, path?: string): string;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { AstContext } from "./ast.js";
|
|
2
|
+
import { type PathAlias } from "./path-aliases.js";
|
|
3
|
+
import type { PlanContext } from "./plan-context.js";
|
|
4
|
+
import type { ManualStep } from "./types.js";
|
|
5
|
+
type JsonObject = Record<string, unknown>;
|
|
6
|
+
/** What `rebase.json` says about the layout, read raw (the CLI's parser refuses the legacy keys). */
|
|
7
|
+
export interface RawManifest {
|
|
8
|
+
file: string;
|
|
9
|
+
text: string;
|
|
10
|
+
value: JsonObject;
|
|
11
|
+
/** The backend app's key in `apps`. */
|
|
12
|
+
backendName?: string;
|
|
13
|
+
/** The config directory, relative to the root. */
|
|
14
|
+
configDir: string;
|
|
15
|
+
/** The frontend (static) app's root, relative to the root, when there is one. */
|
|
16
|
+
frontendRoot?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Read `rebase.json`, if there is one. */
|
|
19
|
+
export declare function readRawManifest(root: string): RawManifest;
|
|
20
|
+
/** `rebase.json` without `config` and `usersCollection` (the tables directory is the default, so no `tables` key). */
|
|
21
|
+
export declare function planManifest(plan: PlanContext, manifest: RawManifest): void;
|
|
22
|
+
/** The workspace, the packages and the scripts that named the config package or directory. */
|
|
23
|
+
export declare function planWorkspace(plan: PlanContext, configDir: string, frontendRoot: string | undefined, keepConfigPackage?: boolean): void;
|
|
24
|
+
/**
|
|
25
|
+
* backend/tsconfig.json once `config/` is gone: `../config/**` out of
|
|
26
|
+
* `include` and the new modules in; `rootDir ".."` (which existed only so the
|
|
27
|
+
* program could reach ../config) back to `"."`, its comment and the include's
|
|
28
|
+
* comment rid of the config package; a `drizzle.config.ts` include that names
|
|
29
|
+
* no file dropped. With `rootDir "."` the emit moves from `dist/backend/src` to
|
|
30
|
+
* `dist/src`, so the scripts, `entrypoint.sh` and Dockerfile that name the old
|
|
31
|
+
* path follow. A tsconfig not in that shape is a manual step.
|
|
32
|
+
*/
|
|
33
|
+
export declare function planBackendTsconfig(plan: PlanContext, wanted: readonly string[], keepConfig?: boolean): void;
|
|
34
|
+
/** A legacy config module that moves to `backend/`, with its imports moved. */
|
|
35
|
+
export declare function planMove(plan: PlanContext, from: string, to: string, role: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* The file the collection editor writes presentation to in development, as
|
|
38
|
+
* `rebase init` ships it (`templates/template/frontend/src/cms/ui-config.json`),
|
|
39
|
+
* and the two lines that mount it — the import and the `<RebaseCMS>` prop.
|
|
40
|
+
*/
|
|
41
|
+
export declare const UI_CONFIG_CONTENT = "{\n \"tables\": {}\n}\n";
|
|
42
|
+
/** The frontend's wiring: `App.tsx`, `vite.config.ts`, `virtual.d.ts`, `src/cms/ui-config.json`. */
|
|
43
|
+
export declare function planFrontendWiring(plan: PlanContext, frontendDir: string, hasExternal: boolean): void;
|
|
44
|
+
/**
|
|
45
|
+
* The other static apps `rebase.json` declares (a public site beside the
|
|
46
|
+
* panel): `rebase build` refuses every one whose Vite config lacks
|
|
47
|
+
* `rebaseBackendGuard()`, not only `frontend/`. Each without it is a manual
|
|
48
|
+
* step — the codemod does not add a dependency on `@rebasepro/app` to an app
|
|
49
|
+
* that may not have one.
|
|
50
|
+
*/
|
|
51
|
+
export declare function planStaticAppGuards(plan: PlanContext, frontendDir: string | undefined): void;
|
|
52
|
+
/** Files of `config/` nothing the codemod moved needs, which the user should look at before deleting the directory. */
|
|
53
|
+
export declare function unmovedConfigFiles(plan: PlanContext, configDir: string, handled: ReadonlySet<string>): string[];
|
|
54
|
+
/** Where a module that imported something from `config/` should import it from now. */
|
|
55
|
+
export interface ConfigImporter {
|
|
56
|
+
file: string;
|
|
57
|
+
line: number;
|
|
58
|
+
/** As written: relative, or through a path alias (`@config/collections/posts`). */
|
|
59
|
+
specifier: string;
|
|
60
|
+
/** The same import written relative to the file (equal to `specifier` when it was). */
|
|
61
|
+
relativeSpecifier: string;
|
|
62
|
+
target: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Every module outside `config/` that imports something inside it — a custom
|
|
66
|
+
* backend entry importing `config/collections/users`, a test importing a
|
|
67
|
+
* collection — relative, or through a path alias the project's tsconfig
|
|
68
|
+
* `paths` or Vite `resolve.alias` declares. After the migration those imports
|
|
69
|
+
* point at nothing.
|
|
70
|
+
*
|
|
71
|
+
* @param skip files the run rewrites itself
|
|
72
|
+
*/
|
|
73
|
+
export declare function findConfigImporters(root: string, configDir: string, skip: ReadonlySet<string>, aliases?: readonly PathAlias[]): ConfigImporter[];
|
|
74
|
+
/** A use of a server API the table model renamed. */
|
|
75
|
+
export interface LegacyApiUse {
|
|
76
|
+
file: string;
|
|
77
|
+
line: number;
|
|
78
|
+
/** The legacy name as written. */
|
|
79
|
+
api: string;
|
|
80
|
+
/** What it is now. */
|
|
81
|
+
replacement: string;
|
|
82
|
+
}
|
|
83
|
+
/** Every use of a renamed collection-model server API in the project's own code (outside `config/`). */
|
|
84
|
+
export declare function findLegacyApiUses(root: string, configDir: string, skip: ReadonlySet<string>, handled?: ReadonlySet<string>): LegacyApiUse[];
|
|
85
|
+
/**
|
|
86
|
+
* The modules of `config/` that are the project's own: everything but what
|
|
87
|
+
* Rebase read — `config/collections`, the wiring the run moves to `backend/`
|
|
88
|
+
* (`resources.ts`, `storage.ts`, `generated/register.ts`), the package's index,
|
|
89
|
+
* declarations and package files. 0.31 stops reading `config/collections`, not
|
|
90
|
+
* `config/`: these stay where they are, importable as before.
|
|
91
|
+
*
|
|
92
|
+
* @param moved the wiring files the run moves, absolute
|
|
93
|
+
*/
|
|
94
|
+
export declare function keptConfigModules(plan: PlanContext, configDir: string, collectionsDir: string, moved: readonly string[]): string[];
|
|
95
|
+
/**
|
|
96
|
+
* The kept modules of `config/` nothing will import once the run is written:
|
|
97
|
+
* no file outside `config/` (read as the run leaves it), no kept module that is
|
|
98
|
+
* itself imported, and not the kept `config/index.ts`. A module whose only
|
|
99
|
+
* importers were the collections is dead weight once they are tables — it goes
|
|
100
|
+
* in the printed `git rm` line instead of staying as "the project's own".
|
|
101
|
+
*
|
|
102
|
+
* @param kept the kept modules, absolute
|
|
103
|
+
* @param removed files the run removes or moves (collections, moved wiring, a dropped index), absolute
|
|
104
|
+
* @param indexKept whether `config/index.ts` stays (its imports are live: the package entry)
|
|
105
|
+
*/
|
|
106
|
+
export declare function unimportedConfigModules(plan: PlanContext, configDir: string, kept: readonly string[], removed: readonly string[], indexKept: boolean, aliases?: readonly PathAlias[]): string[];
|
|
107
|
+
/**
|
|
108
|
+
* Build and deploy files that name what the migration removes: the config
|
|
109
|
+
* workspace package by name (`pnpm --filter "<name>" run build`, a deploy
|
|
110
|
+
* workspace list, an `allowBuilds` entry) when the package goes, and the
|
|
111
|
+
* collections directory (`COPY config/collections`, a watcher on
|
|
112
|
+
* `../config/**`). The run rewrites `pnpm-workspace.yaml` and the manifests it
|
|
113
|
+
* owns; read as it leaves them, whatever still names these is a step per file
|
|
114
|
+
* with its lines — the codemod does not edit a Dockerfile or a CI pipeline.
|
|
115
|
+
*
|
|
116
|
+
* @param packageGoes whether the config package is removed (nothing of the project's own is left in it)
|
|
117
|
+
*/
|
|
118
|
+
export declare function findDeployReferences(plan: PlanContext, configDir: string, collectionsDir: string, packageGoes: boolean): ManualStep[];
|
|
119
|
+
/** The names a module's text exports (`export { a, b as c }`, `export const x`); `export *` is not followed. */
|
|
120
|
+
export declare function exportedNamesOf(text: string): Set<string>;
|
|
121
|
+
/**
|
|
122
|
+
* The project's own code that still reads what the migration removes from
|
|
123
|
+
* `config/` in a way no import rewrite can fix — each a manual step with
|
|
124
|
+
* file:line, since the codemod cannot rewrite an assertion:
|
|
125
|
+
*
|
|
126
|
+
* - an import of a name `config/index.ts` no longer exports (`collections`,
|
|
127
|
+
* `storageAuthorize`, … — the re-exports of what Rebase read), relative, through
|
|
128
|
+
* a path alias, or by the config package's name;
|
|
129
|
+
* - a file that reads `config/collections` as TEXT (`readFileSync`, `readdirSync`,
|
|
130
|
+
* a path built with `path.join(…, "config", "collections")`): a test asserting
|
|
131
|
+
* over the collection files' source, a script listing them.
|
|
132
|
+
*
|
|
133
|
+
* @param removedIndexNames what the index exported before the run and does not after
|
|
134
|
+
* (every export when the index goes)
|
|
135
|
+
*/
|
|
136
|
+
export declare function findLegacyConfigReads(plan: PlanContext, configDir: string, collectionsDir: string, removedIndexNames: ReadonlySet<string>, aliases?: readonly PathAlias[]): ManualStep[];
|
|
137
|
+
/**
|
|
138
|
+
* `config/index.ts` without its re-exports of what Rebase read
|
|
139
|
+
* (`export { collections } from "./collections"`, `export { storageAuthorize }
|
|
140
|
+
* from "./storage"`), so the package keeps exporting the project's own modules.
|
|
141
|
+
* Undefined when nothing but comments would be left: the index goes too.
|
|
142
|
+
*/
|
|
143
|
+
export declare function withoutRebaseReexports(ctx: AstContext, indexFile: string, collectionsDir: string, moved: readonly string[]): string | undefined;
|
|
144
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { PlanContext } from "./plan-context.js";
|
|
2
|
+
import type { ConfigImporter } from "./project-files.js";
|
|
3
|
+
/** A table a collection file became. */
|
|
4
|
+
export interface TableHome {
|
|
5
|
+
/** The exported identifier (`posts`). */
|
|
6
|
+
identifier: string;
|
|
7
|
+
/** The table module, absolute. */
|
|
8
|
+
file: string;
|
|
9
|
+
/** The customization module and its export, when one was written. */
|
|
10
|
+
cms?: {
|
|
11
|
+
identifier: string;
|
|
12
|
+
file: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** What {@link repointConfigImports} needs to know about the run. */
|
|
16
|
+
export interface RepointContext {
|
|
17
|
+
configDir: string;
|
|
18
|
+
collectionsDir: string;
|
|
19
|
+
/** Collection files (absolute) → the table each became. */
|
|
20
|
+
tables: ReadonlyMap<string, TableHome>;
|
|
21
|
+
/** Rebase's own modules the run moved (absolute legacy path → new path). */
|
|
22
|
+
movedWiring: ReadonlyMap<string, string>;
|
|
23
|
+
/** Whether `config/index.ts` is removed (it re-exported nothing but what moved). */
|
|
24
|
+
indexRemoved: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** An import repointed to a table module, whose uses are checked once the run's rewrites are done. */
|
|
27
|
+
export interface TableBinding {
|
|
28
|
+
/** The importing file, absolute. */
|
|
29
|
+
file: string;
|
|
30
|
+
/** The local name. */
|
|
31
|
+
local: string;
|
|
32
|
+
/** The table it now names. */
|
|
33
|
+
table: TableHome;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Rewrite the project's imports of what the migration removes from `config/`,
|
|
37
|
+
* planning each rewritten file; what cannot be rewritten is a manual step per
|
|
38
|
+
* file. Returns the bindings now naming a table, for {@link tableUseSteps}.
|
|
39
|
+
*/
|
|
40
|
+
export declare function repointConfigImports(plan: PlanContext, ctx: RepointContext, importers: readonly ConfigImporter[]): TableBinding[];
|
|
41
|
+
/**
|
|
42
|
+
* The uses of a binding repointed to a table that read it as an object, one
|
|
43
|
+
* step per file, given the files as the run writes them (after the SDK
|
|
44
|
+
* rewrite, which may have removed a use, as `auth.collection`). A table
|
|
45
|
+
* definition is not a collection: `columns`, `hooks`, `rls` where a collection
|
|
46
|
+
* had `properties`, `callbacks`, `securityRules`.
|
|
47
|
+
*
|
|
48
|
+
* @param read a file's content as the run writes it
|
|
49
|
+
*/
|
|
50
|
+
export declare function tableUseSteps(plan: PlanContext, bindings: readonly TableBinding[], read: (file: string) => string): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PlanContext } from "./plan-context.js";
|
|
2
|
+
/**
|
|
3
|
+
* Rewrite or list the row-shaped hands in the frontend (planned contents first).
|
|
4
|
+
*
|
|
5
|
+
* @returns nothing; planned files are updated and one grouped step is pushed
|
|
6
|
+
*/
|
|
7
|
+
export declare function planRowShapedHands(plan: PlanContext, frontendDir: string): void;
|