@kendroger/io-snapshot 1.0.0 → 1.0.1
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/bin/cli.js +4 -5
- package/lib/constants.js +0 -1
- package/lib/paths.js +0 -19
- package/lib/transformer.js +6 -13
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -106,10 +106,9 @@ program
|
|
|
106
106
|
]);
|
|
107
107
|
|
|
108
108
|
const snapshotPath = path.resolve(process.cwd(), SNAPSHOT_FILE);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
109
|
+
// Explicitly overwrite with an empty string at the start of 'record'
|
|
110
|
+
fs.writeFileSync(snapshotPath, '');
|
|
111
|
+
log.info('Cleared previous snapshot file for a fresh session.');
|
|
113
112
|
|
|
114
113
|
log.info('Checking for existing io-snapshot session...');
|
|
115
114
|
const savedPid = getSavedPid();
|
|
@@ -153,7 +152,7 @@ program
|
|
|
153
152
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
154
153
|
|
|
155
154
|
log.step(3, 'Starting recording...');
|
|
156
|
-
|
|
155
|
+
|
|
157
156
|
try {
|
|
158
157
|
await daemonRequest('/record', port);
|
|
159
158
|
log.success('Recording started.');
|
package/lib/constants.js
CHANGED
|
@@ -4,7 +4,6 @@ export const SNAPSHOT_FILE = '.snaps.jsonl'; // In project root
|
|
|
4
4
|
export const TEMP_SESSION_DIR_PREFIX = 'io-snapshot-session-';
|
|
5
5
|
export const TEMP_SUBDIR_NAME = '.io-snapshot'; // Subdirectory within the session temp dir
|
|
6
6
|
export const PID_FILE_NAME = '.io-snapshot.pid'; // In the session temp dir
|
|
7
|
-
export const RECORDER_FILE_NAME = 'recorder.js'; // In the session temp dir
|
|
8
7
|
export const LOCAL_BACKUP_DIR = '.io-snapshot-local-backups';
|
|
9
8
|
export const CONFIG_FILE = '.iosnapshotrc.json';
|
|
10
9
|
export const BACKUP_EXT = '.snap.bak';
|
package/lib/paths.js
CHANGED
|
@@ -25,29 +25,10 @@ export function getTempSessionDirPath() {
|
|
|
25
25
|
return _tempSessionDirPath;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export function getRecorderPath() {
|
|
29
|
-
return path.join(getTempSessionDirPath(), TEMP_SUBDIR_NAME, RECORDER_FILE_NAME);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
28
|
export function getPidFilePath() {
|
|
33
29
|
return path.join(getTempSessionDirPath(), PID_FILE_NAME);
|
|
34
30
|
}
|
|
35
31
|
|
|
36
|
-
export function getRecorderDir() {
|
|
37
|
-
return path.join(getTempSessionDirPath(), TEMP_SUBDIR_NAME);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function ensureTempSessionDir() {
|
|
41
|
-
const dirPath = getTempSessionDirPath();
|
|
42
|
-
if (!fs.existsSync(dirPath)) {
|
|
43
|
-
fs.mkdirSync(dirPath, { recursive: true });
|
|
44
|
-
}
|
|
45
|
-
const recorderDirPath = getRecorderDir();
|
|
46
|
-
if (!fs.existsSync(recorderDirPath)) {
|
|
47
|
-
fs.mkdirSync(recorderDirPath, { recursive: true });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
32
|
// Gets the path for the primary backup in the OS temp directory
|
|
52
33
|
export function getPrimaryBackupPath(filePath) {
|
|
53
34
|
const relativePath = path.relative(process.cwd(), filePath);
|
package/lib/transformer.js
CHANGED
|
@@ -68,20 +68,13 @@ function injectTSFile(filePath) {
|
|
|
68
68
|
|
|
69
69
|
log.info('Injecting recorder import');
|
|
70
70
|
|
|
71
|
-
//
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
const imports = sourceFile.getImportDeclarations();
|
|
75
|
-
const hasRecorderImport = imports.some(
|
|
76
|
-
imp => imp.getModuleSpecifierValue?.().includes(relativeRecorderPath)
|
|
77
|
-
);
|
|
71
|
+
// Use the package name directly
|
|
72
|
+
const recorderModule = "@kendroger/io-snapshot/recorder";
|
|
78
73
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
});
|
|
84
|
-
}
|
|
74
|
+
sourceFile.addImportDeclaration({
|
|
75
|
+
moduleSpecifier: recorderModule,
|
|
76
|
+
namedImports: ['_snap_record']
|
|
77
|
+
});
|
|
85
78
|
|
|
86
79
|
const exports = sourceFile.getExportedDeclarations();
|
|
87
80
|
log.info(`Found ${exports.size} exported declarations`);
|