@baseplate-dev/project-builder-server 0.2.5 → 0.3.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/api/index.d.ts +3 -3
- package/dist/api/sync.d.ts +3 -3
- package/dist/compiler/app-entry-builder.d.ts +1 -2
- package/dist/compiler/app-entry-builder.d.ts.map +1 -1
- package/dist/compiler/app-entry-builder.js +3 -5
- package/dist/compiler/app-entry-builder.js.map +1 -1
- package/dist/compiler/index.d.ts.map +1 -1
- package/dist/compiler/index.js +0 -4
- package/dist/compiler/index.js.map +1 -1
- package/dist/compiler/web/admin/crud/displays.d.ts +5 -0
- package/dist/compiler/web/admin/crud/displays.d.ts.map +1 -0
- package/dist/compiler/web/admin/crud/displays.js.map +1 -0
- package/dist/compiler/web/admin/crud/index.d.ts +5 -0
- package/dist/compiler/web/admin/crud/index.d.ts.map +1 -0
- package/dist/compiler/web/admin/crud/index.js.map +1 -0
- package/dist/compiler/web/admin/crud/inputs.d.ts +5 -0
- package/dist/compiler/web/admin/crud/inputs.d.ts.map +1 -0
- package/dist/compiler/web/admin/crud/inputs.js.map +1 -0
- package/dist/compiler/web/admin/index.d.ts +5 -0
- package/dist/compiler/web/admin/index.d.ts.map +1 -0
- package/dist/compiler/web/admin/index.js +10 -0
- package/dist/compiler/web/admin/index.js.map +1 -0
- package/dist/compiler/web/admin/sections.d.ts +5 -0
- package/dist/compiler/web/admin/sections.d.ts.map +1 -0
- package/dist/compiler/{admin → web/admin}/sections.js +2 -1
- package/dist/compiler/web/admin/sections.js.map +1 -0
- package/dist/compiler/web/index.d.ts.map +1 -1
- package/dist/compiler/web/index.js +72 -6
- package/dist/compiler/web/index.js.map +1 -1
- package/dist/diff/diff-project.d.ts.map +1 -1
- package/dist/diff/diff-project.js +22 -5
- package/dist/diff/diff-project.js.map +1 -1
- package/dist/diff/diff-utils.d.ts +7 -3
- package/dist/diff/diff-utils.d.ts.map +1 -1
- package/dist/diff/diff-utils.js +80 -22
- package/dist/diff/diff-utils.js.map +1 -1
- package/dist/diff/index.d.ts +1 -0
- package/dist/diff/index.d.ts.map +1 -1
- package/dist/diff/index.js +1 -0
- package/dist/diff/index.js.map +1 -1
- package/dist/diff/snapshot/apply-diff-to-file-contents.d.ts +3 -0
- package/dist/diff/snapshot/apply-diff-to-file-contents.d.ts.map +1 -0
- package/dist/diff/snapshot/apply-diff-to-file-contents.js +26 -0
- package/dist/diff/snapshot/apply-diff-to-file-contents.js.map +1 -0
- package/dist/diff/snapshot/apply-diff-to-generator-output.d.ts +4 -0
- package/dist/diff/snapshot/apply-diff-to-generator-output.d.ts.map +1 -0
- package/dist/diff/snapshot/apply-diff-to-generator-output.js +28 -0
- package/dist/diff/snapshot/apply-diff-to-generator-output.js.map +1 -0
- package/dist/diff/snapshot/create-snapshot-for-project.d.ts +41 -0
- package/dist/diff/snapshot/create-snapshot-for-project.d.ts.map +1 -0
- package/dist/diff/snapshot/create-snapshot-for-project.js +48 -0
- package/dist/diff/snapshot/create-snapshot-for-project.js.map +1 -0
- package/dist/diff/snapshot/index.d.ts +6 -0
- package/dist/diff/snapshot/index.d.ts.map +1 -0
- package/dist/diff/snapshot/index.js +5 -0
- package/dist/diff/snapshot/index.js.map +1 -0
- package/dist/diff/snapshot/save-snapshot.d.ts +25 -0
- package/dist/diff/snapshot/save-snapshot.d.ts.map +1 -0
- package/dist/diff/snapshot/save-snapshot.js +55 -0
- package/dist/diff/snapshot/save-snapshot.js.map +1 -0
- package/dist/diff/snapshot/snapshot-diff-utils.d.ts +7 -0
- package/dist/diff/snapshot/snapshot-diff-utils.d.ts.map +1 -0
- package/dist/diff/snapshot/snapshot-diff-utils.js +20 -0
- package/dist/diff/snapshot/snapshot-diff-utils.js.map +1 -0
- package/dist/diff/snapshot/snapshot-management.d.ts +31 -0
- package/dist/diff/snapshot/snapshot-management.d.ts.map +1 -0
- package/dist/diff/snapshot/snapshot-management.js +154 -0
- package/dist/diff/snapshot/snapshot-management.js.map +1 -0
- package/dist/diff/snapshot/snapshot-manifest.d.ts +40 -0
- package/dist/diff/snapshot/snapshot-manifest.d.ts.map +1 -0
- package/dist/diff/snapshot/snapshot-manifest.js +113 -0
- package/dist/diff/snapshot/snapshot-manifest.js.map +1 -0
- package/dist/diff/snapshot/snapshot-types.d.ts +165 -0
- package/dist/diff/snapshot/snapshot-types.d.ts.map +1 -0
- package/dist/diff/snapshot/snapshot-types.js +23 -0
- package/dist/diff/snapshot/snapshot-types.js.map +1 -0
- package/dist/diff/snapshot/snapshot-utils.d.ts +20 -0
- package/dist/diff/snapshot/snapshot-utils.d.ts.map +1 -0
- package/dist/diff/snapshot/snapshot-utils.js +51 -0
- package/dist/diff/snapshot/snapshot-utils.js.map +1 -0
- package/dist/diff/types.d.ts +38 -6
- package/dist/diff/types.d.ts.map +1 -1
- package/dist/project-definition/get-single-app-directory-for-project.d.ts +11 -0
- package/dist/project-definition/get-single-app-directory-for-project.d.ts.map +1 -0
- package/dist/project-definition/get-single-app-directory-for-project.js +18 -0
- package/dist/project-definition/get-single-app-directory-for-project.js.map +1 -0
- package/dist/project-definition/index.d.ts +2 -0
- package/dist/project-definition/index.d.ts.map +1 -0
- package/dist/project-definition/index.js +2 -0
- package/dist/project-definition/index.js.map +1 -0
- package/dist/project-definition/load-project-definition.d.ts +12 -0
- package/dist/project-definition/load-project-definition.d.ts.map +1 -0
- package/dist/project-definition/load-project-definition.js +34 -0
- package/dist/project-definition/load-project-definition.js.map +1 -0
- package/dist/server/plugin.js +6 -6
- package/dist/server/plugin.js.map +1 -1
- package/dist/sync/generate-for-directory.d.ts +5 -14
- package/dist/sync/generate-for-directory.d.ts.map +1 -1
- package/dist/sync/generate-for-directory.js +37 -30
- package/dist/sync/generate-for-directory.js.map +1 -1
- package/dist/sync/get-previous-generated-payload.d.ts +9 -0
- package/dist/sync/get-previous-generated-payload.d.ts.map +1 -0
- package/dist/sync/get-previous-generated-payload.js +23 -0
- package/dist/sync/get-previous-generated-payload.js.map +1 -0
- package/dist/sync/sync-project.d.ts +7 -3
- package/dist/sync/sync-project.d.ts.map +1 -1
- package/dist/sync/sync-project.js +5 -29
- package/dist/sync/sync-project.js.map +1 -1
- package/dist/sync/types.d.ts +14 -0
- package/dist/sync/types.d.ts.map +1 -0
- package/dist/sync/types.js +15 -0
- package/dist/sync/types.js.map +1 -0
- package/package.json +12 -11
- package/dist/compiler/admin/crud/displays.d.ts +0 -5
- package/dist/compiler/admin/crud/displays.d.ts.map +0 -1
- package/dist/compiler/admin/crud/displays.js.map +0 -1
- package/dist/compiler/admin/crud/index.d.ts +0 -5
- package/dist/compiler/admin/crud/index.d.ts.map +0 -1
- package/dist/compiler/admin/crud/index.js.map +0 -1
- package/dist/compiler/admin/crud/inputs.d.ts +0 -5
- package/dist/compiler/admin/crud/inputs.d.ts.map +0 -1
- package/dist/compiler/admin/crud/inputs.js.map +0 -1
- package/dist/compiler/admin/index.d.ts +0 -3
- package/dist/compiler/admin/index.d.ts.map +0 -1
- package/dist/compiler/admin/index.js +0 -102
- package/dist/compiler/admin/index.js.map +0 -1
- package/dist/compiler/admin/sections.d.ts +0 -5
- package/dist/compiler/admin/sections.d.ts.map +0 -1
- package/dist/compiler/admin/sections.js.map +0 -1
- /package/dist/compiler/{admin → web/admin}/crud/displays.js +0 -0
- /package/dist/compiler/{admin → web/admin}/crud/index.js +0 -0
- /package/dist/compiler/{admin → web/admin}/crud/inputs.js +0 -0
package/dist/diff/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/diff/types.ts"],"names":[],"mappings":"AAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/diff/types.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,aAAc,SAAQ,YAAY;IAC1C,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,KAAK,C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MAAM,EAAE,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ProjectDefinition } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
/**
|
|
3
|
+
* Given a project directory, get the app directory for that project
|
|
4
|
+
*
|
|
5
|
+
* @param projectDirectory The absolute path to the project directory
|
|
6
|
+
* @param app The name of the app which will be matched
|
|
7
|
+
*
|
|
8
|
+
* @throws Error if there are more than one apps matching the name (or none)
|
|
9
|
+
*/
|
|
10
|
+
export declare function getSingleAppDirectoryForProject(projectDirectory: string, projectDefinition: ProjectDefinition, app: string): string;
|
|
11
|
+
//# sourceMappingURL=get-single-app-directory-for-project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-single-app-directory-for-project.d.ts","sourceRoot":"","sources":["../../src/project-definition/get-single-app-directory-for-project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAK5E;;;;;;;GAOG;AACH,wBAAgB,+BAA+B,CAC7C,gBAAgB,EAAE,MAAM,EACxB,iBAAiB,EAAE,iBAAiB,EACpC,GAAG,EAAE,MAAM,GACV,MAAM,CAUR"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AppUtils } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Given a project directory, get the app directory for that project
|
|
5
|
+
*
|
|
6
|
+
* @param projectDirectory The absolute path to the project directory
|
|
7
|
+
* @param app The name of the app which will be matched
|
|
8
|
+
*
|
|
9
|
+
* @throws Error if there are more than one apps matching the name (or none)
|
|
10
|
+
*/
|
|
11
|
+
export function getSingleAppDirectoryForProject(projectDirectory, projectDefinition, app) {
|
|
12
|
+
const matchedApps = projectDefinition.apps.find((a) => a.name === app);
|
|
13
|
+
if (!matchedApps) {
|
|
14
|
+
throw new Error(`Unable to find app ${app} in project definition. Available apps: ${projectDefinition.apps.map((a) => a.name).join(', ')}`);
|
|
15
|
+
}
|
|
16
|
+
return path.join(projectDirectory, AppUtils.getAppDirectory(matchedApps));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=get-single-app-directory-for-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-single-app-directory-for-project.js","sourceRoot":"","sources":["../../src/project-definition/get-single-app-directory-for-project.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAC9D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;;GAOG;AACH,MAAM,UAAU,+BAA+B,CAC7C,gBAAwB,EACxB,iBAAoC,EACpC,GAAW;IAEX,MAAM,WAAW,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;IAEvE,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,sBAAsB,GAAG,2CAA2C,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC3H,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/project-definition/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/project-definition/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ProjectDefinition, SchemaParserContext } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
/**
|
|
3
|
+
* Loads the project definition from the given directory and runs migrations on it.
|
|
4
|
+
* @param directory - The directory to load the project definition from.
|
|
5
|
+
* @param context - The context to use for parsing the project.
|
|
6
|
+
* @returns The project definition and the hash of the project definition.
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadProjectDefinition(directory: string, context: SchemaParserContext): Promise<{
|
|
9
|
+
definition: ProjectDefinition;
|
|
10
|
+
hash: string;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=load-project-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-project-definition.d.ts","sourceRoot":"","sources":["../../src/project-definition/load-project-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,oCAAoC,CAAC;AAgB5C;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC;IAAE,UAAU,EAAE,iBAAiB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CA6C1D"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createPluginImplementationStore, runPluginMigrations, runSchemaMigrations, } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import { enhanceErrorWithContext, hashWithSHA256, stringifyPrettyStable, } from '@baseplate-dev/utils';
|
|
3
|
+
import { fileExists } from '@baseplate-dev/utils/node';
|
|
4
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
/**
|
|
7
|
+
* Loads the project definition from the given directory and runs migrations on it.
|
|
8
|
+
* @param directory - The directory to load the project definition from.
|
|
9
|
+
* @param context - The context to use for parsing the project.
|
|
10
|
+
* @returns The project definition and the hash of the project definition.
|
|
11
|
+
*/
|
|
12
|
+
export async function loadProjectDefinition(directory, context) {
|
|
13
|
+
const projectJsonPath = path.join(directory, 'baseplate/project-definition.json');
|
|
14
|
+
const projectJsonExists = await fileExists(projectJsonPath);
|
|
15
|
+
if (!projectJsonExists) {
|
|
16
|
+
throw new Error(`Could not find definition file at ${projectJsonPath}`);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const projectJsonContents = await readFile(projectJsonPath, 'utf8');
|
|
20
|
+
const hash = await hashWithSHA256(projectJsonContents);
|
|
21
|
+
const projectJson = JSON.parse(projectJsonContents);
|
|
22
|
+
const { migratedDefinition, appliedMigrations } = runSchemaMigrations(projectJson);
|
|
23
|
+
if (appliedMigrations.length > 0) {
|
|
24
|
+
await writeFile(projectJsonPath, stringifyPrettyStable(migratedDefinition));
|
|
25
|
+
}
|
|
26
|
+
const pluginImplementationStore = createPluginImplementationStore(context.pluginStore, migratedDefinition);
|
|
27
|
+
const definitionWithPluginMigrations = runPluginMigrations(migratedDefinition, pluginImplementationStore);
|
|
28
|
+
return { definition: definitionWithPluginMigrations, hash };
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
throw enhanceErrorWithContext(err, `Error parsing project definition at ${projectJsonPath}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=load-project-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-project-definition.js","sourceRoot":"","sources":["../../src/project-definition/load-project-definition.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,+BAA+B,EAC/B,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;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C;IACJ,CAAC;AACH,CAAC"}
|
package/dist/server/plugin.js
CHANGED
|
@@ -39,11 +39,11 @@ export const baseplatePlugin = async function (fastify, { cliVersion, featureFla
|
|
|
39
39
|
},
|
|
40
40
|
useWSS: true,
|
|
41
41
|
});
|
|
42
|
-
fastify.get('/api/plugins/:projectId/:
|
|
42
|
+
fastify.get('/api/plugins/:projectId/:pluginKey/static/*', {
|
|
43
43
|
schema: {
|
|
44
44
|
params: z.object({
|
|
45
45
|
projectId: z.string().min(1),
|
|
46
|
-
|
|
46
|
+
pluginKey: z.string().min(1),
|
|
47
47
|
'*': z.string(),
|
|
48
48
|
}),
|
|
49
49
|
},
|
|
@@ -55,7 +55,7 @@ export const baseplatePlugin = async function (fastify, { cliVersion, featureFla
|
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
const plugins = await service.getAvailablePlugins();
|
|
58
|
-
const plugin = plugins.find((plugin) => plugin.
|
|
58
|
+
const plugin = plugins.find((plugin) => plugin.key === req.params.pluginKey);
|
|
59
59
|
if (!plugin) {
|
|
60
60
|
reply.status(404).send('No plugin with provided ID found');
|
|
61
61
|
return;
|
|
@@ -71,11 +71,11 @@ export const baseplatePlugin = async function (fastify, { cliVersion, featureFla
|
|
|
71
71
|
},
|
|
72
72
|
});
|
|
73
73
|
// serve remoteEntry.js for plugins
|
|
74
|
-
fastify.get('/api/plugins/:projectId/:
|
|
74
|
+
fastify.get('/api/plugins/:projectId/:pluginKey/web/*', {
|
|
75
75
|
schema: {
|
|
76
76
|
params: z.object({
|
|
77
77
|
projectId: z.string().min(1),
|
|
78
|
-
|
|
78
|
+
pluginKey: z.string().min(1),
|
|
79
79
|
'*': z.string(),
|
|
80
80
|
}),
|
|
81
81
|
},
|
|
@@ -87,7 +87,7 @@ export const baseplatePlugin = async function (fastify, { cliVersion, featureFla
|
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
89
|
const plugins = await service.getAvailablePlugins();
|
|
90
|
-
const plugin = plugins.find((plugin) => plugin.
|
|
90
|
+
const plugin = plugins.find((plugin) => plugin.key === req.params.pluginKey);
|
|
91
91
|
if (!plugin) {
|
|
92
92
|
reply.status(404).send('No plugin with provided ID found');
|
|
93
93
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/server/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD,MAAM,CAAC,MAAM,eAAe,GAMvB,KAAK,WACR,OAAO,EACP,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE;IAEpE,OAAO,CAAC,GAAG,CAAC,IAAI,CACd,qBAAqB,cAAc;SAChC,WAAW,EAAE;SACb,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC;SAC3C,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB,CAAC;IAEF,MAAM,OAAO,CAAC,QAAQ,CAAC,iBAAiB,EAAE;QACxC,MAAM,EAAE,OAAO;QACf,WAAW,EAAE;YACX,MAAM,EAAE,SAAS;YACjB,aAAa,EAAE,oBAAoB,CAAC;gBAClC,cAAc;gBACd,UAAU;gBACV,MAAM,EAAE,OAAO,CAAC,GAAG;gBACnB,YAAY;gBACZ,UAAU;gBACV,UAAU;aACX,CAAC;YACF,OAAO,EAAE,C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S,EAAE,GAAG,EAAE;QAC9B,cAAc,CAAC,iBAAiB,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { AppEntry } from '@baseplate-dev/project-builder-lib';
|
|
2
|
-
import type {
|
|
3
|
-
import { buildGeneratorEntry, executeGeneratorEntry, writeGeneratorOutput } from '@baseplate-dev/sync';
|
|
2
|
+
import type { Logger, TemplateMetadataOptions } from '@baseplate-dev/sync';
|
|
4
3
|
import type { BaseplateUserConfig } from '#src/user-config/user-config-schema.js';
|
|
5
4
|
import type { PackageSyncResult } from './sync-metadata.js';
|
|
6
|
-
import {
|
|
5
|
+
import type { GeneratorOperations } from './types.js';
|
|
7
6
|
interface GenerateForDirectoryOptions {
|
|
8
7
|
baseDirectory: string;
|
|
9
8
|
appEntry: AppEntry;
|
|
@@ -14,17 +13,9 @@ interface GenerateForDirectoryOptions {
|
|
|
14
13
|
operations?: GeneratorOperations;
|
|
15
14
|
abortSignal?: AbortSignal;
|
|
16
15
|
skipCommands?: boolean;
|
|
17
|
-
|
|
16
|
+
overwrite?: boolean;
|
|
17
|
+
snapshotDirectory?: string;
|
|
18
18
|
}
|
|
19
|
-
export
|
|
20
|
-
buildGeneratorEntry: typeof buildGeneratorEntry;
|
|
21
|
-
executeGeneratorEntry: typeof executeGeneratorEntry;
|
|
22
|
-
getPreviousGeneratedPayload: typeof getPreviousGeneratedPayload;
|
|
23
|
-
writeGeneratorOutput: typeof writeGeneratorOutput;
|
|
24
|
-
writeMetadata: (project: GeneratorEntry, output: GeneratorOutput, projectDirectory: string) => Promise<void>;
|
|
25
|
-
writeGeneratorSteps: typeof writeGeneratorSteps;
|
|
26
|
-
}
|
|
27
|
-
declare function getPreviousGeneratedPayload(projectDirectory: string): Promise<PreviousGeneratedPayload | undefined>;
|
|
28
|
-
export declare function generateForDirectory({ baseDirectory, appEntry, logger, writeTemplateMetadataOptions, userConfig, previousPackageSyncResult, operations, abortSignal, skipCommands, forceOverwrite, }: GenerateForDirectoryOptions): Promise<PackageSyncResult>;
|
|
19
|
+
export declare function generateForDirectory({ baseDirectory, appEntry, logger, writeTemplateMetadataOptions, userConfig, previousPackageSyncResult, operations, abortSignal, skipCommands, overwrite, snapshotDirectory, }: GenerateForDirectoryOptions): Promise<PackageSyncResult>;
|
|
29
20
|
export {};
|
|
30
21
|
//# sourceMappingURL=generate-for-directory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-for-directory.d.ts","sourceRoot":"","sources":["../../src/sync/generate-for-directory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,KAAK,EAEV,
|
|
1
|
+
{"version":3,"file":"generate-for-directory.d.ts","sourceRoot":"","sources":["../../src/sync/generate-for-directory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,KAAK,EAEV,MAAM,EAEN,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAQ7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAIlF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAQtD,UAAU,2BAA2B;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,4BAA4B,CAAC,EAAE,uBAAuB,CAAC;IACvD,UAAU,EAAE,mBAAmB,CAAC;IAChC,yBAAyB,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACzD,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAsB,oBAAoB,CAAC,EACzC,aAAa,EACb,QAAQ,EACR,MAAM,EACN,4BAA4B,EAC5B,UAAU,EACV,yBAAyB,EACzB,UAAyC,EACzC,WAAW,EACX,YAAY,EACZ,SAAS,EACT,iBAAiB,GAClB,EAAE,2BAA2B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAwK1D"}
|
|
@@ -1,36 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CancelledSyncError, loadIgnorePatterns } from '@baseplate-dev/sync';
|
|
2
2
|
import { randomKey } from '@baseplate-dev/utils';
|
|
3
|
-
import { dirExists } from '@baseplate-dev/utils/node';
|
|
4
3
|
import chalk from 'chalk';
|
|
5
4
|
import { mkdir, rename, rm } from 'node:fs/promises';
|
|
6
5
|
import path from 'node:path';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
writeMetadata: async (_project, output, projectDirectory) => {
|
|
15
|
-
await deleteMetadataFiles(projectDirectory);
|
|
16
|
-
await writeTemplateInfoFiles(output.files, projectDirectory);
|
|
17
|
-
},
|
|
18
|
-
writeGeneratorSteps,
|
|
19
|
-
};
|
|
20
|
-
const GENERATED_DIRECTORY = 'baseplate/generated';
|
|
21
|
-
async function getPreviousGeneratedPayload(projectDirectory) {
|
|
22
|
-
const generatedDirectory = path.join(projectDirectory, GENERATED_DIRECTORY);
|
|
23
|
-
const generatedDirectoryExists = await dirExists(generatedDirectory);
|
|
24
|
-
if (!generatedDirectoryExists) {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
const fileIdMap = await getPreviousGeneratedFileIdMap(projectDirectory);
|
|
28
|
-
return {
|
|
29
|
-
fileReader: createCodebaseFileReaderFromDirectory(generatedDirectory),
|
|
30
|
-
fileIdToRelativePathMap: fileIdMap,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export async function generateForDirectory({ baseDirectory, appEntry, logger, writeTemplateMetadataOptions, userConfig, previousPackageSyncResult, operations = defaultGeneratorOperations, abortSignal, skipCommands, forceOverwrite, }) {
|
|
6
|
+
import { applySnapshotToFileContents } from '#src/diff/index.js';
|
|
7
|
+
import { loadSnapshotManifest } from '../diff/snapshot/snapshot-manifest.js';
|
|
8
|
+
import { resolveSnapshotDirectory } from '../diff/snapshot/snapshot-utils.js';
|
|
9
|
+
import { writeGeneratedFileIdMap } from './file-id-map.js';
|
|
10
|
+
import { GENERATED_DIRECTORY } from './get-previous-generated-payload.js';
|
|
11
|
+
import { DEFAULT_GENERATOR_OPERATIONS } from './types.js';
|
|
12
|
+
export async function generateForDirectory({ baseDirectory, appEntry, logger, writeTemplateMetadataOptions, userConfig, previousPackageSyncResult, operations = DEFAULT_GENERATOR_OPERATIONS, abortSignal, skipCommands, overwrite, snapshotDirectory, }) {
|
|
34
13
|
const { appDirectory, name, generatorBundle } = appEntry;
|
|
35
14
|
const projectDirectory = path.join(baseDirectory, appDirectory);
|
|
36
15
|
logger.info(`Generating project ${name} in ${projectDirectory}...`);
|
|
@@ -40,6 +19,10 @@ export async function generateForDirectory({ baseDirectory, appEntry, logger, wr
|
|
|
40
19
|
});
|
|
41
20
|
if (abortSignal?.aborted)
|
|
42
21
|
throw new CancelledSyncError();
|
|
22
|
+
const resolvedSnapshotDirectory = resolveSnapshotDirectory(projectDirectory, {
|
|
23
|
+
snapshotDir: snapshotDirectory,
|
|
24
|
+
});
|
|
25
|
+
const snapshot = await loadSnapshotManifest(resolvedSnapshotDirectory);
|
|
43
26
|
logger.info('Project built! Writing output....');
|
|
44
27
|
// load clean directory contents
|
|
45
28
|
const previousGeneratedPayload = await operations.getPreviousGeneratedPayload(projectDirectory);
|
|
@@ -48,6 +31,30 @@ export async function generateForDirectory({ baseDirectory, appEntry, logger, wr
|
|
|
48
31
|
}
|
|
49
32
|
const generatedTemporaryDirectory = path.join(projectDirectory, 'baseplate/build/generated_tmp');
|
|
50
33
|
await mkdir(generatedTemporaryDirectory, { recursive: true });
|
|
34
|
+
const ignorePatterns = await loadIgnorePatterns(projectDirectory).catch((error) => {
|
|
35
|
+
logger.warn(`Failed to load .baseplateignore patterns, proceeding without ignore filtering: ${String(error)}`);
|
|
36
|
+
return undefined;
|
|
37
|
+
});
|
|
38
|
+
if (overwrite && snapshot) {
|
|
39
|
+
logger.info(`Applying snapshot to generator output for ${name}...`);
|
|
40
|
+
}
|
|
41
|
+
const overwriteOptions = {
|
|
42
|
+
enabled: !!overwrite,
|
|
43
|
+
applyDiff: snapshot &&
|
|
44
|
+
(async (relativePath, generatedContents) => {
|
|
45
|
+
const result = await applySnapshotToFileContents(relativePath, generatedContents, snapshot, resolvedSnapshotDirectory.diffsPath);
|
|
46
|
+
if (result === false) {
|
|
47
|
+
logger.warn(`Snapshot for ${relativePath} was not applied because the patch was invalid. Please verify the new output and run snapshot add once the changes have been verified.`);
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}),
|
|
51
|
+
skipFile: (relativePath) => {
|
|
52
|
+
if (!ignorePatterns) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return ignorePatterns.ignores(relativePath);
|
|
56
|
+
},
|
|
57
|
+
};
|
|
51
58
|
try {
|
|
52
59
|
const { failedCommands, filesWithConflicts, fileIdToRelativePathMap } = await operations.writeGeneratorOutput(output, projectDirectory, {
|
|
53
60
|
previousGeneratedPayload,
|
|
@@ -62,7 +69,7 @@ export async function generateForDirectory({ baseDirectory, appEntry, logger, wr
|
|
|
62
69
|
: undefined,
|
|
63
70
|
abortSignal,
|
|
64
71
|
skipCommands,
|
|
65
|
-
|
|
72
|
+
overwriteOptions,
|
|
66
73
|
});
|
|
67
74
|
// write metadata to the generated directory
|
|
68
75
|
if (writeTemplateMetadataOptions?.includeTemplateMetadata) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-for-directory.js","sourceRoot":"","sources":["../../src/sync/generate-for-directory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-for-directory.js","sourceRoot":"","sources":["../../src/sync/generate-for-directory.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAKjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAgB1D,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,EACzC,aAAa,EACb,QAAQ,EACR,MAAM,EACN,4BAA4B,EAC5B,UAAU,EACV,yBAAyB,EACzB,UAAU,GAAG,4BAA4B,EACzC,WAAW,EACX,YAAY,EACZ,SAAS,EACT,iBAAiB,GACW;IAC5B,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,QAAQ,CAAC;IAEzD,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IAEhE,MAAM,CAAC,IAAI,CAAC,sBAAsB,IAAI,OAAO,gBAAgB,KAAK,CAAC,CAAC;IAEpE,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,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AAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,iBAAiB,CAAC,EACtE,6FAA6F,CAC9F,CAAC;QAEF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,CAAC,KAAK,CACV,yFAAyF,CAC1F,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QACjD,CAAC;QAED,OAAO;YACL,kBAAkB;YAClB,cAAc,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACzC,EAAE,EAAE,SAAS,EAAE;gBACf,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,UAAU,EAAE,CAAC,CAAC,UAAU;gBACxB,MAAM,EAAE,CAAC,CAAC,MAAM;aACjB,CAAC,CAAC;YACH,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACtC,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,4CAA4C;QAC5C,MAAM,EAAE,CAAC,2BAA2B,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;YACpE,mBAAmB;QACrB,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PreviousGeneratedPayload } from '@baseplate-dev/sync';
|
|
2
|
+
export declare const GENERATED_DIRECTORY = "baseplate/generated";
|
|
3
|
+
/**
|
|
4
|
+
* Gets the previous generated payload for a project
|
|
5
|
+
* @param projectDirectory - The directory of the project
|
|
6
|
+
* @returns The previous generated payload
|
|
7
|
+
*/
|
|
8
|
+
export declare function getPreviousGeneratedPayload(projectDirectory: string): Promise<PreviousGeneratedPayload | undefined>;
|
|
9
|
+
//# sourceMappingURL=get-previous-generated-payload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-previous-generated-payload.d.ts","sourceRoot":"","sources":["../../src/sync/get-previous-generated-payload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAQpE,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD;;;;GAIG;AACH,wBAAsB,2BAA2B,CAC/C,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC,CAe/C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createCodebaseFileReaderFromDirectory } from '@baseplate-dev/sync';
|
|
2
|
+
import { dirExists } from '@baseplate-dev/utils/node';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { getPreviousGeneratedFileIdMap } from './file-id-map.js';
|
|
5
|
+
export const GENERATED_DIRECTORY = 'baseplate/generated';
|
|
6
|
+
/**
|
|
7
|
+
* Gets the previous generated payload for a project
|
|
8
|
+
* @param projectDirectory - The directory of the project
|
|
9
|
+
* @returns The previous generated payload
|
|
10
|
+
*/
|
|
11
|
+
export async function getPreviousGeneratedPayload(projectDirectory) {
|
|
12
|
+
const generatedDirectory = path.join(projectDirectory, GENERATED_DIRECTORY);
|
|
13
|
+
const generatedDirectoryExists = await dirExists(generatedDirectory);
|
|
14
|
+
if (!generatedDirectoryExists) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const fileIdMap = await getPreviousGeneratedFileIdMap(projectDirectory);
|
|
18
|
+
return {
|
|
19
|
+
fileReader: createCodebaseFileReaderFromDirectory(generatedDirectory),
|
|
20
|
+
fileIdToRelativePathMap: fileIdMap,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=get-previous-generated-payload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-previous-generated-payload.js","sourceRoot":"","sources":["../../src/sync/get-previous-generated-payload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qCAAqC,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAEjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,gBAAwB;IAExB,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,CAAC;IAE5E,MAAM,wBAAwB,GAAG,MAAM,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAErE,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAC9B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,6BAA6B,CAAC,gBAAgB,CAAC,CAAC;IAExE,OAAO;QACL,UAAU,EAAE,qCAAqC,CAAC,kBAAkB,CAAC;QACrE,uBAAuB,EAAE,SAAS;KACnC,CAAC;AACJ,CAAC"}
|
|
@@ -41,9 +41,13 @@ export interface SyncProjectOptions {
|
|
|
41
41
|
*/
|
|
42
42
|
cliFilePath?: string;
|
|
43
43
|
/**
|
|
44
|
-
* Whether to force overwrite existing files
|
|
44
|
+
* Whether to force overwrite existing files and apply snapshot.
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
overwrite?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Directory containing snapshot to use when generating.
|
|
49
|
+
*/
|
|
50
|
+
snapshotDirectory?: string;
|
|
47
51
|
}
|
|
48
52
|
/**
|
|
49
53
|
* The result of syncing the project.
|
|
@@ -59,5 +63,5 @@ export interface SyncProjectResult {
|
|
|
59
63
|
*
|
|
60
64
|
* @param options - The options for syncing the project.
|
|
61
65
|
*/
|
|
62
|
-
export declare function syncProject({ directory, logger, context, userConfig, syncMetadataController, abortSignal, skipCommands, cliFilePath,
|
|
66
|
+
export declare function syncProject({ directory, logger, context, userConfig, syncMetadataController, abortSignal, skipCommands, cliFilePath, overwrite, snapshotDirectory, }: SyncProjectOptions): Promise<SyncProjectResult>;
|
|
63
67
|
//# sourceMappingURL=sync-project.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-project.d.ts","sourceRoot":"","sources":["../../src/sync/sync-project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sync-project.d.ts","sourceRoot":"","sources":["../../src/sync/sync-project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAOlD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAKlF,OAAO,KAAK,EAAqB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAM5E;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,EAAE,mBAAmB,CAAC;IAC7B;;OAEG;IACH,UAAU,EAAE,mBAAmB,CAAC;IAChC;;OAEG;IACH,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAChD;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,EAChC,SAAS,EACT,MAAM,EACN,OAAO,EACP,UAAU,EACV,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,SAAS,EACT,iBAAiB,GAClB,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAiJjD"}
|
|
@@ -1,43 +1,18 @@
|
|
|
1
|
-
import { createPluginImplementationStore, runPluginMigrations, runSchemaMigrations, } from '@baseplate-dev/project-builder-lib';
|
|
2
1
|
import { CancelledSyncError } from '@baseplate-dev/sync';
|
|
3
|
-
import { enhanceErrorWithContext, hashWithSHA256, stringifyPrettyStable, } from '@baseplate-dev/utils';
|
|
4
|
-
import { fileExists } from '@baseplate-dev/utils/node';
|
|
5
2
|
import { mapValues } from 'es-toolkit';
|
|
6
|
-
import { readFile, writeFile } from 'node:fs/promises';
|
|
7
3
|
import path from 'node:path';
|
|
8
4
|
import { stripVTControlCharacters } from 'node:util';
|
|
9
5
|
import { compileApplications } from '#src/compiler/index.js';
|
|
6
|
+
import { loadProjectDefinition } from '#src/project-definition/load-project-definition.js';
|
|
10
7
|
import { generateForDirectory } from '../sync/generate-for-directory.js';
|
|
11
8
|
import { createTemplateMetadataOptions } from './template-metadata-utils.js';
|
|
12
9
|
import { getPackageSyncStatusFromResult } from './utils.js';
|
|
13
|
-
async function loadProjectJson(directory, context) {
|
|
14
|
-
const projectJsonPath = path.join(directory, 'baseplate/project-definition.json');
|
|
15
|
-
const projectJsonExists = await fileExists(projectJsonPath);
|
|
16
|
-
if (!projectJsonExists) {
|
|
17
|
-
throw new Error(`Could not find definition file at ${projectJsonPath}`);
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
const projectJsonContents = await readFile(projectJsonPath, 'utf8');
|
|
21
|
-
const hash = await hashWithSHA256(projectJsonContents);
|
|
22
|
-
const projectJson = JSON.parse(projectJsonContents);
|
|
23
|
-
const { migratedDefinition, appliedMigrations } = runSchemaMigrations(projectJson);
|
|
24
|
-
if (appliedMigrations.length > 0) {
|
|
25
|
-
await writeFile(projectJsonPath, stringifyPrettyStable(migratedDefinition));
|
|
26
|
-
}
|
|
27
|
-
const pluginImplementationStore = createPluginImplementationStore(context.pluginStore, migratedDefinition);
|
|
28
|
-
const definitionWithPluginMigrations = runPluginMigrations(migratedDefinition, pluginImplementationStore);
|
|
29
|
-
return { definition: definitionWithPluginMigrations, hash };
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
throw enhanceErrorWithContext(err, `Error parsing project definition at ${projectJsonPath}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
10
|
/**
|
|
36
11
|
* Syncs the project in the given directory.
|
|
37
12
|
*
|
|
38
13
|
* @param options - The options for syncing the project.
|
|
39
14
|
*/
|
|
40
|
-
export async function syncProject({ directory, logger, context, userConfig, syncMetadataController, abortSignal, skipCommands, cliFilePath,
|
|
15
|
+
export async function syncProject({ directory, logger, context, userConfig, syncMetadataController, abortSignal, skipCommands, cliFilePath, overwrite, snapshotDirectory, }) {
|
|
41
16
|
await syncMetadataController?.updateMetadata((metadata) => ({
|
|
42
17
|
...metadata,
|
|
43
18
|
status: 'in-progress',
|
|
@@ -50,7 +25,7 @@ export async function syncProject({ directory, logger, context, userConfig, sync
|
|
|
50
25
|
})),
|
|
51
26
|
}));
|
|
52
27
|
try {
|
|
53
|
-
const { definition: projectJson } = await
|
|
28
|
+
const { definition: projectJson } = await loadProjectDefinition(directory, context);
|
|
54
29
|
const apps = compileApplications(projectJson, context);
|
|
55
30
|
await syncMetadataController?.updateMetadata((metadata) => ({
|
|
56
31
|
...metadata,
|
|
@@ -96,7 +71,8 @@ export async function syncProject({ directory, logger, context, userConfig, sync
|
|
|
96
71
|
previousPackageSyncResult: packageInfo?.result,
|
|
97
72
|
abortSignal,
|
|
98
73
|
skipCommands,
|
|
99
|
-
|
|
74
|
+
overwrite,
|
|
75
|
+
snapshotDirectory,
|
|
100
76
|
});
|
|
101
77
|
}
|
|
102
78
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-project.js","sourceRoot":"","sources":["../../src/sync/sync-project.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync-project.js","sourceRoot":"","sources":["../../src/sync/sync-project.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAIrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAK3F,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AA2D5D;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,EAChC,SAAS,EACT,MAAM,EACN,OAAO,EACP,UAAU,EACV,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,SAAS,EACT,iBAAiB,GACE;IACnB,MAAM,sBAAsB,EAAE,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC1D,GAAG,QAAQ;QACX,MAAM,EAAE,aAAa;QACrB,YAAY,EAAE,SAAS;QACvB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,qDAAqD;QACrD,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YACvD,GAAG,WAAW;YACd,MAAM,EAAE,YA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sBAAsB,EAAE,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC1D,GAAG,QAAQ;YACX,MAAM,EAAE,OAAO;YACf,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACrC,YAAY,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SAC5B,CAAC,CAAC,CAAC;QACJ,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACrC,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GeneratorEntry, GeneratorOutput } from '@baseplate-dev/sync';
|
|
2
|
+
import { buildGeneratorEntry, executeGeneratorEntry, writeGeneratorOutput } from '@baseplate-dev/sync';
|
|
3
|
+
import { writeGeneratorSteps } from './generator-steps-writer.js';
|
|
4
|
+
import { getPreviousGeneratedPayload } from './get-previous-generated-payload.js';
|
|
5
|
+
export interface GeneratorOperations {
|
|
6
|
+
buildGeneratorEntry: typeof buildGeneratorEntry;
|
|
7
|
+
executeGeneratorEntry: typeof executeGeneratorEntry;
|
|
8
|
+
getPreviousGeneratedPayload: typeof getPreviousGeneratedPayload;
|
|
9
|
+
writeGeneratorOutput: typeof writeGeneratorOutput;
|
|
10
|
+
writeMetadata: (project: GeneratorEntry, output: GeneratorOutput, projectDirectory: string) => Promise<void>;
|
|
11
|
+
writeGeneratorSteps: typeof writeGeneratorSteps;
|
|
12
|
+
}
|
|
13
|
+
export declare const DEFAULT_GENERATOR_OPERATIONS: GeneratorOperations;
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/sync/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EACL,mBAAmB,EAEnB,qBAAqB,EACrB,oBAAoB,EAErB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAElF,MAAM,WAAW,mBAAmB;IAClC,mBAAmB,EAAE,OAAO,mBAAmB,CAAC;IAChD,qBAAqB,EAAE,OAAO,qBAAqB,CAAC;IACpD,2BAA2B,EAAE,OAAO,2BAA2B,CAAC;IAChE,oBAAoB,EAAE,OAAO,oBAAoB,CAAC;IAClD,aAAa,EAAE,CACb,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,eAAe,EACvB,gBAAgB,EAAE,MAAM,KACrB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,mBAAmB,EAAE,OAAO,mBAAmB,CAAC;CACjD;AAED,eAAO,MAAM,4BAA4B,EAAE,mBAU1C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { buildGeneratorEntry, deleteMetadataFiles, executeGeneratorEntry, writeGeneratorOutput, writeTemplateInfoFiles, } from '@baseplate-dev/sync';
|
|
2
|
+
import { writeGeneratorSteps } from './generator-steps-writer.js';
|
|
3
|
+
import { getPreviousGeneratedPayload } from './get-previous-generated-payload.js';
|
|
4
|
+
export const DEFAULT_GENERATOR_OPERATIONS = {
|
|
5
|
+
buildGeneratorEntry,
|
|
6
|
+
executeGeneratorEntry,
|
|
7
|
+
getPreviousGeneratedPayload,
|
|
8
|
+
writeGeneratorOutput,
|
|
9
|
+
writeMetadata: async (_project, output, projectDirectory) => {
|
|
10
|
+
await deleteMetadataFiles(projectDirectory);
|
|
11
|
+
await writeTemplateInfoFiles(output.files, projectDirectory);
|
|
12
|
+
},
|
|
13
|
+
writeGeneratorSteps,
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/sync/types.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAelF,MAAM,CAAC,MAAM,4BAA4B,GAAwB;IAC/D,mBAAmB;IACnB,qBAAqB;IACrB,2BAA2B;IAC3B,oBAAoB;IACpB,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,EAAE;QAC1D,MAAM,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;QAC5C,MAAM,sBAAsB,CAAC,MAAM,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;IAC/D,CAAC;IACD,mBAAmB;CACpB,CAAC"}
|