dorky 4.1.0 → 4.1.2
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 +2 -1
- package/bin/index.js +28 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -191,6 +191,7 @@ This command:
|
|
|
191
191
|
- Updates modified files (based on hash comparison)
|
|
192
192
|
- Removes files from remote storage that were unstaged using `dorky --rm`
|
|
193
193
|
- Skips unchanged files
|
|
194
|
+
- Skips push entirely if the staged state already matches the latest commit
|
|
194
195
|
|
|
195
196
|
### Pull Files from Storage (`-pl`)
|
|
196
197
|
|
|
@@ -220,7 +221,7 @@ Prints all past push commits in reverse chronological order, showing the commit
|
|
|
220
221
|
dorky --checkout <commit-id>
|
|
221
222
|
```
|
|
222
223
|
|
|
223
|
-
Downloads the files as they were at the given commit from remote storage and
|
|
224
|
+
Downloads the files as they were at the given commit from remote storage and stages them locally. Run `dorky --push` afterward to publish the restored state as a new commit. The commit ID can be found with `--log`. Prefix matching is supported (e.g. `dorky --checkout a1b2` if the full ID is `a1b2c3d4`).
|
|
224
225
|
|
|
225
226
|
### Destroy Project (`-d`)
|
|
226
227
|
|
package/bin/index.js
CHANGED
|
@@ -278,6 +278,11 @@ async function push() {
|
|
|
278
278
|
|
|
279
279
|
if (filesToUpload.length === 0 && filesToDelete.length === 0) return console.log(chalk.yellow("ℹ Nothing to push."));
|
|
280
280
|
|
|
281
|
+
const commitFiles = { ...meta["stage-1-files"] };
|
|
282
|
+
const commitId = md5(JSON.stringify(commitFiles)).slice(0, 8);
|
|
283
|
+
const history = existsSync(HISTORY_PATH) ? JSON.parse(readFileSync(HISTORY_PATH)) : [];
|
|
284
|
+
if (history.length > 0 && history[history.length - 1].id === commitId) return console.log(chalk.yellow("ℹ Already on the latest commit. Nothing to push."));
|
|
285
|
+
|
|
281
286
|
const creds = readJson(CREDENTIALS_PATH);
|
|
282
287
|
if (creds.storage === "aws") {
|
|
283
288
|
await runS3(creds, async (s3, bucket) => {
|
|
@@ -331,35 +336,30 @@ async function push() {
|
|
|
331
336
|
meta["uploaded-files"] = { ...meta["stage-1-files"] };
|
|
332
337
|
writeJson(METADATA_PATH, meta);
|
|
333
338
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
const history = existsSync(HISTORY_PATH) ? JSON.parse(readFileSync(HISTORY_PATH)) : [];
|
|
337
|
-
if (!history.find(e => e.id === commitId)) {
|
|
338
|
-
history.push({ id: commitId, timestamp: new Date().toISOString(), files: commitFiles });
|
|
339
|
-
writeJson(HISTORY_PATH, history);
|
|
339
|
+
history.push({ id: commitId, timestamp: new Date().toISOString(), files: commitFiles });
|
|
340
|
+
writeJson(HISTORY_PATH, history);
|
|
340
341
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
console.log(chalk.cyan(`ℹ History commit saved: ${commitId}`));
|
|
342
|
+
const root = path.basename(process.cwd());
|
|
343
|
+
const historyPrefix = path.join(root, ".dorky-history", commitId);
|
|
344
|
+
if (creds.storage === "aws") {
|
|
345
|
+
await runS3(creds, async (s3, bucket) => {
|
|
346
|
+
await Promise.all(Object.keys(commitFiles).map(async f => {
|
|
347
|
+
const key = path.join(historyPrefix, f);
|
|
348
|
+
await s3.send(new PutObjectCommand({ Bucket: bucket, Key: key, Body: readFileSync(f) }));
|
|
349
|
+
}));
|
|
350
|
+
});
|
|
351
|
+
} else if (creds.storage === "google-drive") {
|
|
352
|
+
await runDrive(async (drive) => {
|
|
353
|
+
for (const f of Object.keys(commitFiles)) {
|
|
354
|
+
const parentId = await getFolderId(path.join(root, ".dorky-history", commitId, path.dirname(f)), drive);
|
|
355
|
+
await drive.files.create({
|
|
356
|
+
requestBody: { name: path.basename(f), parents: [parentId] },
|
|
357
|
+
media: { mimeType: commitFiles[f]["mime-type"], body: createReadStream(f) }
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
});
|
|
362
361
|
}
|
|
362
|
+
console.log(chalk.cyan(`ℹ History commit saved: ${commitId}`));
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
async function pull() {
|
|
@@ -455,9 +455,8 @@ async function checkout(commitId) {
|
|
|
455
455
|
|
|
456
456
|
const meta = readJson(METADATA_PATH);
|
|
457
457
|
meta["stage-1-files"] = { ...entry.files };
|
|
458
|
-
meta["uploaded-files"] = { ...entry.files };
|
|
459
458
|
writeJson(METADATA_PATH, meta);
|
|
460
|
-
console.log(chalk.cyan(`\nℹ Staged
|
|
459
|
+
console.log(chalk.cyan(`\nℹ Staged state restored to commit ${entry.id}. Run --push to publish this state.`));
|
|
461
460
|
}
|
|
462
461
|
|
|
463
462
|
async function destroy() {
|