@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
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { enhanceErrorWithContext } from '@baseplate-dev/utils';
|
|
2
|
+
import { handleFileNotFoundError } from '@baseplate-dev/utils/node';
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { compileApplications } from '#src/compiler/index.js';
|
|
6
|
+
import { getSingleAppDirectoryForProject } from '#src/project-definition/get-single-app-directory-for-project.js';
|
|
7
|
+
import { loadProjectDefinition } from '#src/project-definition/index.js';
|
|
8
|
+
import { createTemplateMetadataOptions } from '#src/sync/template-metadata-utils.js';
|
|
9
|
+
import { DEFAULT_GENERATOR_OPERATIONS } from '#src/sync/types.js';
|
|
10
|
+
import { removeSnapshotDiffFile, saveSnapshotDiffFile, } from './snapshot-diff-utils.js';
|
|
11
|
+
import { initializeSnapshotManifest, loadSnapshotManifest, saveSnapshotManifest, snapshotManifestUtils, } from './snapshot-manifest.js';
|
|
12
|
+
import { resolveSnapshotDirectory } from './snapshot-utils.js';
|
|
13
|
+
/**
|
|
14
|
+
* Adds files to snapshot
|
|
15
|
+
*/
|
|
16
|
+
export async function addFilesToSnapshot(relativePaths, isDeleted, { projectDirectory, snapshotDirectory, appName, context, logger, generatorOperations = DEFAULT_GENERATOR_OPERATIONS, }) {
|
|
17
|
+
try {
|
|
18
|
+
const { definition } = await loadProjectDefinition(projectDirectory, context);
|
|
19
|
+
const compiledApps = compileApplications(definition, context);
|
|
20
|
+
const compiledApp = compiledApps.find((a) => a.name === appName);
|
|
21
|
+
if (!compiledApp) {
|
|
22
|
+
throw new Error(`App ${appName} not found`);
|
|
23
|
+
}
|
|
24
|
+
const appDirectory = path.join(projectDirectory, compiledApp.appDirectory);
|
|
25
|
+
const snapshotDirectories = resolveSnapshotDirectory(appDirectory, {
|
|
26
|
+
snapshotDir: snapshotDirectory,
|
|
27
|
+
});
|
|
28
|
+
logger.info(`Generating project to create snapshot...`);
|
|
29
|
+
const appEntry = await generatorOperations.buildGeneratorEntry(compiledApp.generatorBundle);
|
|
30
|
+
const { files: generatedFiles } = await generatorOperations.executeGeneratorEntry(appEntry, {
|
|
31
|
+
templateMetadataOptions: createTemplateMetadataOptions(definition),
|
|
32
|
+
});
|
|
33
|
+
// Load existing manifest
|
|
34
|
+
let manifest = (await loadSnapshotManifest(snapshotDirectories)) ??
|
|
35
|
+
initializeSnapshotManifest();
|
|
36
|
+
for (const relativePath of relativePaths) {
|
|
37
|
+
const absolutePath = path.join(appDirectory, relativePath);
|
|
38
|
+
if (isDeleted) {
|
|
39
|
+
if (!generatedFiles.get(relativePath)) {
|
|
40
|
+
throw new Error(`File not found in generated output: ${relativePath}`);
|
|
41
|
+
}
|
|
42
|
+
// Mark file as intentionally deleted
|
|
43
|
+
logger.info(`Adding deleted file to snapshot: ${relativePath}`);
|
|
44
|
+
manifest = snapshotManifestUtils.addDeletedFile(manifest, relativePath);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// Add existing file with diff
|
|
48
|
+
const workingContent = await readFile(absolutePath, 'utf8').catch(handleFileNotFoundError);
|
|
49
|
+
if (!workingContent) {
|
|
50
|
+
throw new Error(`File not found: ${absolutePath}. Use --deleted flag for deleted files.`);
|
|
51
|
+
}
|
|
52
|
+
const generatedContent = generatedFiles.get(relativePath)?.contents;
|
|
53
|
+
if (generatedContent) {
|
|
54
|
+
if (Buffer.isBuffer(generatedContent)) {
|
|
55
|
+
throw new TypeError(`Diffing binary contents is not currently supported.`);
|
|
56
|
+
}
|
|
57
|
+
if (generatedContent === workingContent) {
|
|
58
|
+
logger.warn(`File ${relativePath} is unchanged. Skipping snapshot generation.`);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const diffFileName = await saveSnapshotDiffFile(snapshotDirectories, relativePath, generatedContent, workingContent);
|
|
62
|
+
manifest = snapshotManifestUtils.addModifiedFile(manifest, relativePath, diffFileName);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// Mark file as added
|
|
66
|
+
manifest = snapshotManifestUtils.addAddedFile(manifest, relativePath);
|
|
67
|
+
}
|
|
68
|
+
logger.info(`Adding file to snapshot: ${relativePath}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Save updated manifest
|
|
72
|
+
await saveSnapshotManifest(snapshotDirectories, manifest);
|
|
73
|
+
logger.info(`✓ Added ${relativePaths.length} file(s) to snapshot`);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
throw enhanceErrorWithContext(error, `Failed to add files to snapshot`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Removes files from snapshot
|
|
81
|
+
*/
|
|
82
|
+
export async function removeFilesFromSnapshot(relativePaths, { projectDirectory, appName, snapshotDirectory, context, logger, }) {
|
|
83
|
+
try {
|
|
84
|
+
const { definition } = await loadProjectDefinition(projectDirectory, context);
|
|
85
|
+
const appDirectory = getSingleAppDirectoryForProject(projectDirectory, definition, appName);
|
|
86
|
+
const snapshotDir = resolveSnapshotDirectory(appDirectory, {
|
|
87
|
+
snapshotDir: snapshotDirectory,
|
|
88
|
+
});
|
|
89
|
+
// Load existing manifest
|
|
90
|
+
let manifest = await loadSnapshotManifest(snapshotDir);
|
|
91
|
+
if (!manifest) {
|
|
92
|
+
throw new Error(`Snapshot not found at ${snapshotDir.path}`);
|
|
93
|
+
}
|
|
94
|
+
for (const relativePath of relativePaths) {
|
|
95
|
+
const modifiedFile = manifest.files.modified.find((entry) => entry.path === relativePath);
|
|
96
|
+
if (modifiedFile?.diffFile) {
|
|
97
|
+
await removeSnapshotDiffFile(snapshotDir, modifiedFile.diffFile);
|
|
98
|
+
}
|
|
99
|
+
manifest = snapshotManifestUtils.removeFile(manifest, relativePath);
|
|
100
|
+
}
|
|
101
|
+
// Save updated manifest
|
|
102
|
+
await saveSnapshotManifest(snapshotDir, manifest);
|
|
103
|
+
logger.info(`✓ Removed ${relativePaths.length} file(s) from snapshot`);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
logger.error(`Failed to remove files from snapshot: ${error.message}`);
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Lists snapshot contents
|
|
112
|
+
*/
|
|
113
|
+
export async function listSnapshotContents({ projectDirectory, snapshotDirectory, appName, context, logger, }) {
|
|
114
|
+
try {
|
|
115
|
+
const { definition } = await loadProjectDefinition(projectDirectory, context);
|
|
116
|
+
const appDirectory = getSingleAppDirectoryForProject(projectDirectory, definition, appName);
|
|
117
|
+
const snapshotDir = resolveSnapshotDirectory(appDirectory, {
|
|
118
|
+
snapshotDir: snapshotDirectory,
|
|
119
|
+
});
|
|
120
|
+
// Load manifest
|
|
121
|
+
const manifest = await loadSnapshotManifest(snapshotDir);
|
|
122
|
+
if (!manifest) {
|
|
123
|
+
throw new Error(`Snapshot not found at ${snapshotDir.path}`);
|
|
124
|
+
}
|
|
125
|
+
logger.info(`Snapshot contents (${snapshotDir.path}):`);
|
|
126
|
+
if (manifest.files.modified.length > 0) {
|
|
127
|
+
logger.info(`\\nModified files (${manifest.files.modified.length}):`);
|
|
128
|
+
for (const entry of manifest.files.modified) {
|
|
129
|
+
logger.info(` ${entry.path}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (manifest.files.added.length > 0) {
|
|
133
|
+
logger.info(`\\nAdded files (${manifest.files.added.length}):`);
|
|
134
|
+
for (const file of manifest.files.added) {
|
|
135
|
+
logger.info(` ${file}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (manifest.files.deleted.length > 0) {
|
|
139
|
+
logger.info(`\\nDeleted files (${manifest.files.deleted.length}):`);
|
|
140
|
+
for (const file of manifest.files.deleted) {
|
|
141
|
+
logger.info(` ${file}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (manifest.files.modified.length === 0 &&
|
|
145
|
+
manifest.files.added.length === 0 &&
|
|
146
|
+
manifest.files.deleted.length === 0) {
|
|
147
|
+
logger.info(' (empty)');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
throw enhanceErrorWithContext(error, `Failed to list snapshot contents`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=snapshot-management.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-management.js","sourceRoot":"","sources":["../../../src/diff/snapshot/snapshot-management.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,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AC;YAChE,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;gBACxC,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QAED,IAAI,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtC,MAAM,CAAC,IAAI,CAAC,qBAAqB,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;YACpE,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;gBAC1C,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QAED,IACE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;YACpC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;YACjC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EACnC,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,uBAAuB,CAAC,KAAK,EAAE,kCAAkC,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { SnapshotDirectory, SnapshotManifest } from './snapshot-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new snapshot manifest
|
|
4
|
+
*/
|
|
5
|
+
export declare function initializeSnapshotManifest(): SnapshotManifest;
|
|
6
|
+
/**
|
|
7
|
+
* Saves a manifest to the snapshot directory
|
|
8
|
+
*/
|
|
9
|
+
export declare function saveSnapshotManifest(snapshotDirectory: SnapshotDirectory, manifest: SnapshotManifest): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Loads a manifest from the snapshot directory
|
|
12
|
+
*/
|
|
13
|
+
export declare function loadSnapshotManifest(snapshotDirectory: SnapshotDirectory): Promise<SnapshotManifest | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Adds a modified file entry to the manifest
|
|
16
|
+
*/
|
|
17
|
+
declare function addModifiedFile(manifest: SnapshotManifest, filePath: string, diffFile: string): SnapshotManifest;
|
|
18
|
+
/**
|
|
19
|
+
* Adds an added file to the manifest
|
|
20
|
+
*/
|
|
21
|
+
declare function addAddedFile(manifest: SnapshotManifest, filePath: string): SnapshotManifest;
|
|
22
|
+
/**
|
|
23
|
+
* Adds a deleted file to the manifest
|
|
24
|
+
*/
|
|
25
|
+
declare function addDeletedFile(manifest: SnapshotManifest, filePath: string): SnapshotManifest;
|
|
26
|
+
/**
|
|
27
|
+
* Removes a file from the manifest
|
|
28
|
+
*/
|
|
29
|
+
declare function removeFile(manifest: SnapshotManifest, filePath: string): SnapshotManifest;
|
|
30
|
+
/**
|
|
31
|
+
* Utilities for working with snapshot manifests
|
|
32
|
+
*/
|
|
33
|
+
export declare const snapshotManifestUtils: {
|
|
34
|
+
addModifiedFile: typeof addModifiedFile;
|
|
35
|
+
addAddedFile: typeof addAddedFile;
|
|
36
|
+
addDeletedFile: typeof addDeletedFile;
|
|
37
|
+
removeFile: typeof removeFile;
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=snapshot-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-manifest.d.ts","sourceRoot":"","sources":["../../../src/diff/snapshot/snapshot-manifest.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAI/E;;GAEG;AACH,wBAAgB,0BAA0B,IAAI,gBAAgB,CAS7D;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,iBAAiB,EAAE,iBAAiB,GACnC,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAOvC;AAED;;GAEG;AACH,iBAAS,eAAe,CACtB,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,gBAAgB,CAWlB;AAED;;GAEG;AACH,iBAAS,YAAY,CACnB,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,MAAM,GACf,gBAAgB,CAYlB;AAED;;GAEG;AACH,iBAAS,cAAc,CACrB,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,MAAM,GACf,gBAAgB,CAYlB;AAED;;GAEG;AACH,iBAAS,UAAU,CACjB,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,MAAM,GACf,gBAAgB,CAYlB;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;CAMjC,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { stringifyPrettyStable } from '@baseplate-dev/utils';
|
|
2
|
+
import { handleFileNotFoundError, readJsonWithSchema, } from '@baseplate-dev/utils/node';
|
|
3
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { SNAPSHOT_VERSION, snapshotManifestSchema } from './snapshot-types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new snapshot manifest
|
|
8
|
+
*/
|
|
9
|
+
export function initializeSnapshotManifest() {
|
|
10
|
+
return {
|
|
11
|
+
version: SNAPSHOT_VERSION,
|
|
12
|
+
files: {
|
|
13
|
+
modified: [],
|
|
14
|
+
added: [],
|
|
15
|
+
deleted: [],
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Saves a manifest to the snapshot directory
|
|
21
|
+
*/
|
|
22
|
+
export async function saveSnapshotManifest(snapshotDirectory, manifest) {
|
|
23
|
+
const sortedManifest = {
|
|
24
|
+
version: manifest.version,
|
|
25
|
+
files: {
|
|
26
|
+
added: manifest.files.added.toSorted(),
|
|
27
|
+
deleted: manifest.files.deleted.toSorted(),
|
|
28
|
+
modified: manifest.files.modified.toSorted((a, b) => a.path.localeCompare(b.path)),
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
const manifestContent = stringifyPrettyStable(sortedManifest);
|
|
32
|
+
await mkdir(path.dirname(snapshotDirectory.manifestPath), {
|
|
33
|
+
recursive: true,
|
|
34
|
+
});
|
|
35
|
+
await writeFile(snapshotDirectory.manifestPath, manifestContent, 'utf8');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Loads a manifest from the snapshot directory
|
|
39
|
+
*/
|
|
40
|
+
export async function loadSnapshotManifest(snapshotDirectory) {
|
|
41
|
+
const manifestData = await readJsonWithSchema(snapshotDirectory.manifestPath, snapshotManifestSchema).catch(handleFileNotFoundError);
|
|
42
|
+
return manifestData;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Adds a modified file entry to the manifest
|
|
46
|
+
*/
|
|
47
|
+
function addModifiedFile(manifest, filePath, diffFile) {
|
|
48
|
+
return {
|
|
49
|
+
...manifest,
|
|
50
|
+
files: {
|
|
51
|
+
...manifest.files,
|
|
52
|
+
modified: [
|
|
53
|
+
...manifest.files.modified.filter((entry) => entry.path !== filePath),
|
|
54
|
+
{ path: filePath, diffFile },
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Adds an added file to the manifest
|
|
61
|
+
*/
|
|
62
|
+
function addAddedFile(manifest, filePath) {
|
|
63
|
+
if (manifest.files.added.includes(filePath)) {
|
|
64
|
+
return manifest;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
...manifest,
|
|
68
|
+
files: {
|
|
69
|
+
...manifest.files,
|
|
70
|
+
added: [...manifest.files.added, filePath],
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Adds a deleted file to the manifest
|
|
76
|
+
*/
|
|
77
|
+
function addDeletedFile(manifest, filePath) {
|
|
78
|
+
if (manifest.files.deleted.includes(filePath)) {
|
|
79
|
+
return manifest;
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
...manifest,
|
|
83
|
+
files: {
|
|
84
|
+
...manifest.files,
|
|
85
|
+
deleted: [...manifest.files.deleted, filePath],
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Removes a file from the manifest
|
|
91
|
+
*/
|
|
92
|
+
function removeFile(manifest, filePath) {
|
|
93
|
+
return {
|
|
94
|
+
...manifest,
|
|
95
|
+
files: {
|
|
96
|
+
...manifest.files,
|
|
97
|
+
modified: manifest.files.modified.filter((entry) => entry.path !== filePath),
|
|
98
|
+
added: manifest.files.added.filter((path) => path !== filePath),
|
|
99
|
+
deleted: manifest.files.deleted.filter((path) => path !== filePath),
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Utilities for working with snapshot manifests
|
|
105
|
+
*/
|
|
106
|
+
export const snapshotManifestUtils = {
|
|
107
|
+
// Immutable file operations (return new manifest)
|
|
108
|
+
addModifiedFile,
|
|
109
|
+
addAddedFile,
|
|
110
|
+
addDeletedFile,
|
|
111
|
+
removeFile,
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=snapshot-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-manifest.js","sourceRoot":"","sources":["../../../src/diff/snapshot/snapshot-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,E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KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC;SAC/C;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,UAAU,CACjB,QAA0B,EAC1B,QAAgB;IAEhB,OAAO;QACL,GAAG,QAAQ;QACX,KAAK,EAAE;YACL,GAAG,QAAQ,CAAC,KAAK;YACjB,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CACtC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CACnC;YACD,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,QAAQ,CAAC;YAC/D,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,QAAQ,CAAC;SACpE;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,kDAAkD;IAClD,eAAe;IACf,YAAY;IACZ,cAAc;IACd,UAAU;CACX,CAAC"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types and interfaces for the structured directory snapshot system
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import type { FileDiff } from '../types.js';
|
|
6
|
+
export interface SnapshotManifest {
|
|
7
|
+
/** Version of the snapshot format */
|
|
8
|
+
version: string;
|
|
9
|
+
/** Categorized list of files in the snapshot */
|
|
10
|
+
files: SnapshotFiles;
|
|
11
|
+
}
|
|
12
|
+
export interface SnapshotFiles {
|
|
13
|
+
/** Files that were modified (have diffs stored) */
|
|
14
|
+
modified: ModifiedFileEntry[];
|
|
15
|
+
/** Files that were added (exist in generated but not working) */
|
|
16
|
+
added: string[];
|
|
17
|
+
/** Files that were deleted (exist in working but not generated) */
|
|
18
|
+
deleted: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface ModifiedFileEntry {
|
|
21
|
+
/** Relative path to the file */
|
|
22
|
+
path: string;
|
|
23
|
+
/** Name of the diff file in the diffs/ directory */
|
|
24
|
+
diffFile: string;
|
|
25
|
+
}
|
|
26
|
+
export interface SnapshotDirectory {
|
|
27
|
+
/** Path to the snapshot directory */
|
|
28
|
+
path: string;
|
|
29
|
+
/** Path to the manifest.json file */
|
|
30
|
+
manifestPath: string;
|
|
31
|
+
/** Path to the diffs/ subdirectory */
|
|
32
|
+
diffsPath: string;
|
|
33
|
+
}
|
|
34
|
+
export interface SnapshotOptions {
|
|
35
|
+
/** Custom name for the snapshot directory (default: .baseplate-snapshot) */
|
|
36
|
+
snapshotDir?: string;
|
|
37
|
+
/** Whether to use strict comparison mode */
|
|
38
|
+
strict?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface SnapshotComparison {
|
|
41
|
+
/** Files that have new differences not in the snapshot */
|
|
42
|
+
newDifferences: FileDiff[];
|
|
43
|
+
/** Files that match the expected snapshot */
|
|
44
|
+
expectedDifferences: FileDiff[];
|
|
45
|
+
/** Files that were expected in snapshot but are missing */
|
|
46
|
+
missingExpected: string[];
|
|
47
|
+
}
|
|
48
|
+
export interface CompareSnapshotResult {
|
|
49
|
+
/** Comparison results */
|
|
50
|
+
comparison: SnapshotComparison;
|
|
51
|
+
/** Whether the comparison passed (no new differences) */
|
|
52
|
+
passed: boolean;
|
|
53
|
+
/** Summary message describing the results */
|
|
54
|
+
summary: string;
|
|
55
|
+
}
|
|
56
|
+
export interface ApplySnapshotResult {
|
|
57
|
+
/** Number of patches successfully applied */
|
|
58
|
+
appliedPatches: number;
|
|
59
|
+
/** Number of patches that failed */
|
|
60
|
+
failedPatches: number;
|
|
61
|
+
/** Details of any failures */
|
|
62
|
+
failures: PatchFailure[];
|
|
63
|
+
}
|
|
64
|
+
export interface PatchFailure {
|
|
65
|
+
/** Path to the file that failed to patch */
|
|
66
|
+
filePath: string;
|
|
67
|
+
/** Error message describing the failure */
|
|
68
|
+
error: string;
|
|
69
|
+
/** The diff content that failed to apply */
|
|
70
|
+
diffContent: string;
|
|
71
|
+
}
|
|
72
|
+
export declare const SNAPSHOT_VERSION = "1";
|
|
73
|
+
export declare const DEFAULT_SNAPSHOT_DIR = ".baseplate-snapshot";
|
|
74
|
+
export declare const MANIFEST_FILENAME = "manifest.json";
|
|
75
|
+
export declare const DIFFS_DIRNAME = "diffs";
|
|
76
|
+
export declare const modifiedFileEntrySchema: z.ZodObject<{
|
|
77
|
+
path: z.ZodString;
|
|
78
|
+
diffFile: z.ZodString;
|
|
79
|
+
}, "strip", z.ZodTypeAny, {
|
|
80
|
+
path: string;
|
|
81
|
+
diffFile: string;
|
|
82
|
+
}, {
|
|
83
|
+
path: string;
|
|
84
|
+
diffFile: string;
|
|
85
|
+
}>;
|
|
86
|
+
export declare const snapshotFilesSchema: z.ZodObject<{
|
|
87
|
+
modified: z.ZodArray<z.ZodObject<{
|
|
88
|
+
path: z.ZodString;
|
|
89
|
+
diffFile: z.ZodString;
|
|
90
|
+
}, "strip", z.ZodTypeAny, {
|
|
91
|
+
path: string;
|
|
92
|
+
diffFile: string;
|
|
93
|
+
}, {
|
|
94
|
+
path: string;
|
|
95
|
+
diffFile: string;
|
|
96
|
+
}>, "many">;
|
|
97
|
+
added: z.ZodArray<z.ZodString, "many">;
|
|
98
|
+
deleted: z.ZodArray<z.ZodString, "many">;
|
|
99
|
+
}, "strip", z.ZodTypeAny, {
|
|
100
|
+
added: string[];
|
|
101
|
+
modified: {
|
|
102
|
+
path: string;
|
|
103
|
+
diffFile: string;
|
|
104
|
+
}[];
|
|
105
|
+
deleted: string[];
|
|
106
|
+
}, {
|
|
107
|
+
added: string[];
|
|
108
|
+
modified: {
|
|
109
|
+
path: string;
|
|
110
|
+
diffFile: string;
|
|
111
|
+
}[];
|
|
112
|
+
deleted: string[];
|
|
113
|
+
}>;
|
|
114
|
+
export declare const snapshotManifestSchema: z.ZodObject<{
|
|
115
|
+
version: z.ZodString;
|
|
116
|
+
files: z.ZodObject<{
|
|
117
|
+
modified: z.ZodArray<z.ZodObject<{
|
|
118
|
+
path: z.ZodString;
|
|
119
|
+
diffFile: z.ZodString;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
path: string;
|
|
122
|
+
diffFile: string;
|
|
123
|
+
}, {
|
|
124
|
+
path: string;
|
|
125
|
+
diffFile: string;
|
|
126
|
+
}>, "many">;
|
|
127
|
+
added: z.ZodArray<z.ZodString, "many">;
|
|
128
|
+
deleted: z.ZodArray<z.ZodString, "many">;
|
|
129
|
+
}, "strip", z.ZodTypeAny, {
|
|
130
|
+
added: string[];
|
|
131
|
+
modified: {
|
|
132
|
+
path: string;
|
|
133
|
+
diffFile: string;
|
|
134
|
+
}[];
|
|
135
|
+
deleted: string[];
|
|
136
|
+
}, {
|
|
137
|
+
added: string[];
|
|
138
|
+
modified: {
|
|
139
|
+
path: string;
|
|
140
|
+
diffFile: string;
|
|
141
|
+
}[];
|
|
142
|
+
deleted: string[];
|
|
143
|
+
}>;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
version: string;
|
|
146
|
+
files: {
|
|
147
|
+
added: string[];
|
|
148
|
+
modified: {
|
|
149
|
+
path: string;
|
|
150
|
+
diffFile: string;
|
|
151
|
+
}[];
|
|
152
|
+
deleted: string[];
|
|
153
|
+
};
|
|
154
|
+
}, {
|
|
155
|
+
version: string;
|
|
156
|
+
files: {
|
|
157
|
+
added: string[];
|
|
158
|
+
modified: {
|
|
159
|
+
path: string;
|
|
160
|
+
diffFile: string;
|
|
161
|
+
}[];
|
|
162
|
+
deleted: string[];
|
|
163
|
+
};
|
|
164
|
+
}>;
|
|
165
|
+
//# sourceMappingURL=snapshot-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-types.d.ts","sourceRoot":"","sources":["../../../src/diff/snapshot/snapshot-types.ts"],"names":[],"m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AAmB;IAClC,6CAA6C;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,oCAAoC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,QAAQ,EAAE,YAAY,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,eAAO,MAAM,oBAAoB,wBAAwB,CAAC;AAC1D,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AACjD,eAAO,MAAM,aAAa,UAAU,CAAC;AAGrC,eAAO,MAAM,uBAAuB;;;;;;;;;EAGlC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAI9B,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGjC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types and interfaces for the structured directory snapshot system
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export const SNAPSHOT_VERSION = '1';
|
|
6
|
+
export const DEFAULT_SNAPSHOT_DIR = '.baseplate-snapshot';
|
|
7
|
+
export const MANIFEST_FILENAME = 'manifest.json';
|
|
8
|
+
export const DIFFS_DIRNAME = 'diffs';
|
|
9
|
+
// Zod schemas for validation
|
|
10
|
+
export const modifiedFileEntrySchema = z.object({
|
|
11
|
+
path: z.string(),
|
|
12
|
+
diffFile: z.string(),
|
|
13
|
+
});
|
|
14
|
+
export const snapshotFilesSchema = z.object({
|
|
15
|
+
modified: z.array(modifiedFileEntrySchema),
|
|
16
|
+
added: z.array(z.string()),
|
|
17
|
+
deleted: z.array(z.string()),
|
|
18
|
+
});
|
|
19
|
+
export const snapshotManifestSchema = z.object({
|
|
20
|
+
version: z.string(),
|
|
21
|
+
files: snapshotFilesSchema,
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=snapshot-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-types.js","sourceRoot":"","sources":["../../../src/diff/snapshot/snapshot-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA+ExB,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AAC1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AACjD,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC;AAErC,6BAA6B;AAC7B,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,uBAAuB,CAAC;IAC1C,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1B,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CAC7B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,KAAK,EAAE,mBAAmB;CAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SnapshotDirectory, SnapshotOptions } from './snapshot-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a file path to a safe filename for storing diffs
|
|
4
|
+
* Example: "src/components/button.tsx" -> "src_components_button.tsx.diff"
|
|
5
|
+
*/
|
|
6
|
+
export declare function pathToSafeDiffFilename(filePath: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Converts a safe diff filename back to the original file path
|
|
9
|
+
* Example: "src_components_button.tsx.diff" -> "src/components/button.tsx"
|
|
10
|
+
*/
|
|
11
|
+
export declare function safeDiffFilenameToPath(diffFilename: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Creates the snapshot directory structure
|
|
14
|
+
*/
|
|
15
|
+
export declare function createSnapshotDirectory(baseDirectory: string, snapshotDir?: string): Promise<SnapshotDirectory>;
|
|
16
|
+
/**
|
|
17
|
+
* Resolves the snapshot directory paths without creating them
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveSnapshotDirectory(baseDirectory: string, options?: SnapshotOptions): SnapshotDirectory;
|
|
20
|
+
//# sourceMappingURL=snapshot-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-utils.d.ts","sourceRoot":"","sources":["../../../src/diff/snapshot/snapshot-utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAQ9E;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAKnE;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,aAAa,EAAE,MAAM,EACrB,WAAW,GAAE,MAA6B,GACzC,OAAO,CAAC,iBAAiB,CAAC,CAc5B;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,eAAoB,GAC5B,iBAAiB,CAWnB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { mkdir } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { DEFAULT_SNAPSHOT_DIR, DIFFS_DIRNAME, MANIFEST_FILENAME, } from './snapshot-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Converts a file path to a safe filename for storing diffs
|
|
6
|
+
* Example: "src/components/button.tsx" -> "src_components_button.tsx.diff"
|
|
7
|
+
*/
|
|
8
|
+
export function pathToSafeDiffFilename(filePath) {
|
|
9
|
+
return `${filePath.replaceAll(/[/\\]/g, '_')}.diff`;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Converts a safe diff filename back to the original file path
|
|
13
|
+
* Example: "src_components_button.tsx.diff" -> "src/components/button.tsx"
|
|
14
|
+
*/
|
|
15
|
+
export function safeDiffFilenameToPath(diffFilename) {
|
|
16
|
+
if (!diffFilename.endsWith('.diff')) {
|
|
17
|
+
throw new Error(`Invalid diff filename: ${diffFilename}`);
|
|
18
|
+
}
|
|
19
|
+
return diffFilename.slice(0, -5).replaceAll('_', '/');
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates the snapshot directory structure
|
|
23
|
+
*/
|
|
24
|
+
export async function createSnapshotDirectory(baseDirectory, snapshotDir = DEFAULT_SNAPSHOT_DIR) {
|
|
25
|
+
const snapshotPath = path.resolve(baseDirectory, snapshotDir);
|
|
26
|
+
const manifestPath = path.join(snapshotPath, MANIFEST_FILENAME);
|
|
27
|
+
const diffsPath = path.join(snapshotPath, DIFFS_DIRNAME);
|
|
28
|
+
// Create the directories
|
|
29
|
+
await mkdir(snapshotPath, { recursive: true });
|
|
30
|
+
await mkdir(diffsPath, { recursive: true });
|
|
31
|
+
return {
|
|
32
|
+
path: snapshotPath,
|
|
33
|
+
manifestPath,
|
|
34
|
+
diffsPath,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolves the snapshot directory paths without creating them
|
|
39
|
+
*/
|
|
40
|
+
export function resolveSnapshotDirectory(baseDirectory, options = {}) {
|
|
41
|
+
const snapshotDirName = options.snapshotDir ?? DEFAULT_SNAPSHOT_DIR;
|
|
42
|
+
const snapshotPath = path.resolve(baseDirectory, snapshotDirName);
|
|
43
|
+
const manifestPath = path.join(snapshotPath, MANIFEST_FILENAME);
|
|
44
|
+
const diffsPath = path.join(snapshotPath, DIFFS_DIRNAME);
|
|
45
|
+
return {
|
|
46
|
+
path: snapshotPath,
|
|
47
|
+
manifestPath,
|
|
48
|
+
diffsPath,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=snapshot-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-utils.js","sourceRoot":"","sources":["../../../src/diff/snapshot/snapshot-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAE7B;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAgB;IACrD,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,YAAoB;IACzD,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,0BAA0B,YAAY,EAAE,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACxD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,aAAqB,EACrB,cAAsB,oBAAoB;IAE1C,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IAC9D,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;IAEzD,yBAAyB;IACzB,MAAM,KAAK,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAE5C,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,YAAY;QACZ,SAAS;KACV,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACtC,aAAqB,EACrB,UAA2B,EAAE;IAE7B,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,IAAI,oBAAoB,CAAC;IACpE,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAClE,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;IAEzD,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,YAAY;QACZ,SAAS;KACV,CAAC;AACJ,CAAC"}
|
package/dist/diff/types.d.ts
CHANGED
|
@@ -1,11 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
interface BaseFileDiff {
|
|
2
2
|
path: string;
|
|
3
|
-
type: 'added' | 'modified' | 'deleted';
|
|
4
|
-
generatedContent?: string | Buffer;
|
|
5
|
-
workingContent?: string | Buffer;
|
|
6
|
-
isBinary: boolean;
|
|
7
|
-
unifiedDiff?: string;
|
|
8
3
|
}
|
|
4
|
+
interface AddedFileDiff extends BaseFileDiff {
|
|
5
|
+
type: 'added';
|
|
6
|
+
isBinary: false;
|
|
7
|
+
workingContent: string;
|
|
8
|
+
unifiedDiff: string;
|
|
9
|
+
}
|
|
10
|
+
interface AddedFileBinaryDiff extends BaseFileDiff {
|
|
11
|
+
type: 'added';
|
|
12
|
+
isBinary: true;
|
|
13
|
+
workingContent: Buffer;
|
|
14
|
+
}
|
|
15
|
+
interface ModifiedFileDiff extends BaseFileDiff {
|
|
16
|
+
type: 'modified';
|
|
17
|
+
isBinary: false;
|
|
18
|
+
generatedContent: string;
|
|
19
|
+
workingContent: string;
|
|
20
|
+
unifiedDiff: string;
|
|
21
|
+
}
|
|
22
|
+
interface ModifiedFileBinaryDiff extends BaseFileDiff {
|
|
23
|
+
type: 'modified';
|
|
24
|
+
isBinary: true;
|
|
25
|
+
generatedContent: Buffer;
|
|
26
|
+
workingContent: Buffer;
|
|
27
|
+
}
|
|
28
|
+
interface DeletedFileDiff extends BaseFileDiff {
|
|
29
|
+
type: 'deleted';
|
|
30
|
+
isBinary: false;
|
|
31
|
+
generatedContent: string;
|
|
32
|
+
unifiedDiff: string;
|
|
33
|
+
}
|
|
34
|
+
interface DeletedFileBinaryDiff extends BaseFileDiff {
|
|
35
|
+
type: 'deleted';
|
|
36
|
+
isBinary: true;
|
|
37
|
+
generatedContent: Buffer;
|
|
38
|
+
}
|
|
39
|
+
export type FileDiff = AddedFileDiff | AddedFileBinaryDiff | ModifiedFileDiff | ModifiedFileBinaryDiff | DeletedFileDiff | DeletedFileBinaryDiff;
|
|
9
40
|
export interface DiffSummary {
|
|
10
41
|
totalFiles: number;
|
|
11
42
|
addedFiles: number;
|
|
@@ -19,4 +50,5 @@ export interface DiffOptions {
|
|
|
19
50
|
globPatterns?: string[];
|
|
20
51
|
useIgnoreFile?: boolean;
|
|
21
52
|
}
|
|
53
|
+
export {};
|
|
22
54
|
//# sourceMappingURL=types.d.ts.map
|