@datatruck/cli 0.13.0 → 0.13.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.
@@ -273,6 +273,7 @@ class DatatruckRepository extends RepositoryAbstract_1.RepositoryAbstract {
273
273
  basePath: sourcePath,
274
274
  },
275
275
  targetPath: outPath,
276
+ skipNotFoundError: true,
276
277
  concurrency: this.config.fileCopyConcurrency,
277
278
  async onPath({ isDir, entryPath }) {
278
279
  if (isDir)
package/Task/GitTask.js CHANGED
@@ -169,6 +169,7 @@ class GitTask extends TaskAbstract_1.TaskAbstract {
169
169
  basePath: path,
170
170
  },
171
171
  targetPath: outPath,
172
+ skipNotFoundError: true,
172
173
  concurrency: this.config.fileCopyConcurrency,
173
174
  onPath: async ({ entryPath }) => {
174
175
  currentFiles++;
@@ -15,6 +15,7 @@ const path_1 = require("path");
15
15
  exports.sqlDumpTaskDefinition = {
16
16
  type: "object",
17
17
  required: ["password", "hostname", "username", "database"],
18
+ additionalProperties: false,
18
19
  properties: {
19
20
  password: {
20
21
  anyOf: [
@@ -683,6 +683,7 @@
683
683
  "username",
684
684
  "database"
685
685
  ],
686
+ "additionalProperties": false,
686
687
  "properties": {
687
688
  "password": {
688
689
  "anyOf": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datatruck/cli",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "dependencies": {
5
5
  "ajv": "^8.11.0",
6
6
  "async": "^3.2.4",
package/util/fs-util.d.ts CHANGED
@@ -57,6 +57,7 @@ export declare function writePathLists(options: {
57
57
  }>;
58
58
  export declare function copyFileWithStreams(source: string, target: string): Promise<unknown>;
59
59
  export declare function updateFileStats(path: string, fileInfo: Stats): Promise<void>;
60
+ export declare function isNotFoundError(error: unknown): boolean;
60
61
  export declare function cpy(options: {
61
62
  input: {
62
63
  type: "glob";
@@ -77,6 +78,7 @@ export declare function cpy(options: {
77
78
  * @default 1
78
79
  */
79
80
  concurrency?: number;
81
+ skipNotFoundError?: boolean;
80
82
  onPath?: (data: {
81
83
  isDir: boolean;
82
84
  entryPath: string;
package/util/fs-util.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.cpy = exports.updateFileStats = exports.copyFileWithStreams = exports.writePathLists = exports.writeGitIgnoreList = exports.fastglobToGitIgnore = exports.forEachFile = exports.readDir = exports.checkDir = exports.checkFile = exports.readPartialFile = exports.mkTmpDir = exports.fastFolderSizeAsync = exports.tmpDir = exports.sessionTmpDir = exports.parentTmpDir = exports.existsFile = exports.findFile = exports.parsePackageFile = exports.parseFile = exports.parseFileExtensions = exports.readdirIfExists = exports.writeJSONFile = exports.existsDir = exports.ensureEmptyDir = exports.mkdirIfNotExists = exports.isDirEmpty = exports.isLocalDir = exports.isWSLSystem = void 0;
6
+ exports.cpy = exports.isNotFoundError = exports.updateFileStats = exports.copyFileWithStreams = exports.writePathLists = exports.writeGitIgnoreList = exports.fastglobToGitIgnore = exports.forEachFile = exports.readDir = exports.checkDir = exports.checkFile = exports.readPartialFile = exports.mkTmpDir = exports.fastFolderSizeAsync = exports.tmpDir = exports.sessionTmpDir = exports.parentTmpDir = exports.existsFile = exports.findFile = exports.parsePackageFile = exports.parseFile = exports.parseFileExtensions = exports.readdirIfExists = exports.writeJSONFile = exports.existsDir = exports.ensureEmptyDir = exports.mkdirIfNotExists = exports.isDirEmpty = exports.isLocalDir = exports.isWSLSystem = void 0;
7
7
  const globalData_1 = __importDefault(require("../globalData"));
8
8
  const path_util_1 = require("./path-util");
9
9
  const async_1 = require("async");
@@ -373,6 +373,10 @@ async function updateFileStats(path, fileInfo) {
373
373
  await (0, promises_1.chown)(path, fileInfo.uid, fileInfo.gid);
374
374
  }
375
375
  exports.updateFileStats = updateFileStats;
376
+ function isNotFoundError(error) {
377
+ return error.code === "ENOENT";
378
+ }
379
+ exports.isNotFoundError = isNotFoundError;
376
380
  async function cpy(options) {
377
381
  const stats = { paths: 0, files: 0, dirs: 0 };
378
382
  const dirs = new Set();
@@ -410,17 +414,34 @@ async function cpy(options) {
410
414
  stats.files++;
411
415
  // https://github.com/nodejs/node/issues/44261
412
416
  if (exports.isWSLSystem) {
413
- const fileInfo = await (0, promises_1.stat)(entrySourcePath);
414
- const isWritable = (fileInfo.mode & 0o200) === 0o200;
415
- if (!isWritable) {
416
- await copyFileWithStreams(entrySourcePath, entryTargetPath);
417
- await updateFileStats(entryTargetPath, fileInfo);
418
- return;
417
+ let fileInfo;
418
+ try {
419
+ fileInfo = await (0, promises_1.stat)(entrySourcePath);
420
+ }
421
+ catch (error) {
422
+ const skipError = options.skipNotFoundError && isNotFoundError(error);
423
+ if (!skipError)
424
+ throw error;
425
+ }
426
+ if (fileInfo) {
427
+ const isWritable = (fileInfo.mode & 0o200) === 0o200;
428
+ if (!isWritable) {
429
+ await copyFileWithStreams(entrySourcePath, entryTargetPath);
430
+ await updateFileStats(entryTargetPath, fileInfo);
431
+ return;
432
+ }
419
433
  }
420
434
  }
421
- await (0, promises_1.cp)(entrySourcePath, entryTargetPath, {
422
- preserveTimestamps: true,
423
- });
435
+ try {
436
+ await (0, promises_1.cp)(entrySourcePath, entryTargetPath, {
437
+ preserveTimestamps: true,
438
+ });
439
+ }
440
+ catch (error) {
441
+ const skipError = options.skipNotFoundError && isNotFoundError(error);
442
+ if (!skipError)
443
+ throw error;
444
+ }
424
445
  }
425
446
  };
426
447
  const { input } = options;
@@ -45,6 +45,7 @@ export declare type UnzipStreamDataType = {
45
45
  };
46
46
  };
47
47
  export declare function buildArguments(filters: (ZipDataFilterType | string)[]): string[];
48
+ export declare function checkSSEOption(command?: string): Promise<boolean>;
48
49
  export declare function zip(data: ZipDataType): Promise<{
49
50
  folders: number;
50
51
  files: number;
package/util/zip-util.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unzip = exports.zip = exports.buildArguments = void 0;
3
+ exports.unzip = exports.zip = exports.checkSSEOption = exports.buildArguments = void 0;
4
4
  const process_util_1 = require("./process-util");
5
5
  const path_1 = require("path");
6
6
  function buildArguments(filters) {
@@ -60,6 +60,14 @@ function parseZipStream(chunk, buffer, cb) {
60
60
  }
61
61
  }
62
62
  }
63
+ let checkSSEOptionResult;
64
+ async function checkSSEOption(command = "7z") {
65
+ const result = await (0, process_util_1.exec)(command);
66
+ if (typeof checkSSEOptionResult === "boolean")
67
+ return checkSSEOptionResult;
68
+ return (checkSSEOptionResult = result.stdout.includes(" -sse"));
69
+ }
70
+ exports.checkSSEOption = checkSSEOption;
63
71
  async function zip(data) {
64
72
  let result = {
65
73
  folders: 0,
@@ -68,7 +76,9 @@ async function zip(data) {
68
76
  let buffer = {};
69
77
  await (0, process_util_1.exec)(data.command ?? "7z", [
70
78
  "a",
71
- "-mmt1",
79
+ // https://sourceforge.net/p/sevenzip/bugs/2099/,
80
+ // https://github.com/mcmilk/7-Zip/commit/87ba6f01ba3c5b2ce3186bddfe3d7d880639193c#diff-779d6b1bfa6196b288478f78ca96c4d4c6d7ac6cf8be15a28a20dabc9137ca36L515
81
+ ...((await checkSSEOption(data.command)) ? [] : ["-mmt1"]),
72
82
  "-bsp1",
73
83
  ...(data.deleteOnZip ? ["-sdel"] : []),
74
84
  (0, path_1.normalize)(data.output),
@@ -79,9 +89,7 @@ async function zip(data) {
79
89
  cwd: data.path,
80
90
  }, {
81
91
  log: data.verbose ?? false,
82
- stderr: {
83
- toExitCode: true,
84
- },
92
+ onExitCodeError: (data, error) => (data.exitCode > 2 ? error : false),
85
93
  stdout: {
86
94
  onData: (chunk) => {
87
95
  parseZipStream(chunk, buffer, (stream) => {
@@ -113,7 +121,6 @@ function parseUnzipStream(chunk, cb) {
113
121
  async function unzip(data) {
114
122
  return await (0, process_util_1.exec)(data.command ?? "7z", [
115
123
  "x",
116
- "-mmt1",
117
124
  "-bsp1",
118
125
  (0, path_1.normalize)(data.input),
119
126
  ...buildArguments(data.files ?? []),