@datatruck/cli 0.11.4 → 0.11.5

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.
@@ -13,6 +13,7 @@ const string_util_1 = require("../util/string-util");
13
13
  const RepositoryAbstract_1 = require("./RepositoryAbstract");
14
14
  const assert_1 = require("assert");
15
15
  const fast_glob_1 = __importDefault(require("fast-glob"));
16
+ const promises_1 = require("fs/promises");
16
17
  const micromatch_1 = require("micromatch");
17
18
  const path_1 = require("path");
18
19
  exports.resticRepositoryName = "restic";
@@ -174,7 +175,20 @@ class ResticRepository extends RepositoryAbstract_1.RepositoryAbstract {
174
175
  const sourcePath = data.targetPath ?? data.package.path;
175
176
  (0, assert_1.ok)(sourcePath);
176
177
  let gitignorePath;
177
- if (pkg.include || pkg.exclude) {
178
+ if (!pkg.include && pkg.exclude) {
179
+ const exclude = await (0, paths_util_1.parsePaths)(pkg.exclude, {
180
+ cwd: sourcePath,
181
+ verbose: data.options.verbose,
182
+ });
183
+ await data.onProgress({
184
+ step: "Writing excluded paths list...",
185
+ });
186
+ const tmpDir = await (0, fs_util_1.mkTmpDir)("restic-exclude");
187
+ const ignoredContents = (0, fs_util_1.fastglobToGitIgnore)(exclude).join("\n");
188
+ gitignorePath = (0, path_1.join)(tmpDir, "ignored.txt");
189
+ await (0, promises_1.writeFile)(gitignorePath, ignoredContents);
190
+ }
191
+ else if (pkg.include || pkg.exclude) {
178
192
  const include = await (0, paths_util_1.parsePaths)(pkg.include ?? ["**"], {
179
193
  cwd: sourcePath,
180
194
  verbose: data.options.verbose,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datatruck/cli",
3
- "version": "0.11.4",
3
+ "version": "0.11.5",
4
4
  "dependencies": {
5
5
  "ajv": "^8.11.0",
6
6
  "async": "^3.2.4",
package/util/fs-util.d.ts CHANGED
@@ -29,6 +29,10 @@ export declare function checkFile(path: string): Promise<boolean>;
29
29
  export declare function checkDir(path: string): Promise<boolean>;
30
30
  export declare function readDir(path: string): Promise<string[]>;
31
31
  export declare function forEachFile(dirPath: string, cb: (path: string, dir: boolean) => void, includeDir?: boolean): Promise<void>;
32
+ /**
33
+ * @experimental
34
+ */
35
+ export declare function fastglobToGitIgnore(patterns: string[]): string[];
32
36
  export declare function writeGitIgnoreList(options: {
33
37
  paths: NodeJS.ReadableStream | string[];
34
38
  }): Promise<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.forEachFile = exports.readDir = exports.checkDir = exports.checkFile = exports.readPartialFile = exports.mkTmpDir = 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.updateFileStats = exports.copyFileWithStreams = exports.writePathLists = exports.writeGitIgnoreList = exports.fastglobToGitIgnore = exports.forEachFile = exports.readDir = exports.checkDir = exports.checkFile = exports.readPartialFile = exports.mkTmpDir = 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");
@@ -213,6 +213,15 @@ async function forEachFile(dirPath, cb, includeDir) {
213
213
  }
214
214
  }
215
215
  exports.forEachFile = forEachFile;
216
+ /**
217
+ * @experimental
218
+ */
219
+ function fastglobToGitIgnore(patterns) {
220
+ // https://github.com/mrmlnc/fast-glob#readme
221
+ // https://git-scm.com/docs/gitignore
222
+ return patterns.map((p) => (p.startsWith("/") ? p : `/${p}`));
223
+ }
224
+ exports.fastglobToGitIgnore = fastglobToGitIgnore;
216
225
  async function writeGitIgnoreList(options) {
217
226
  const tempDir = await mkTmpDir("gitignore-list");
218
227
  const path = (0, path_1.join)(tempDir, `.gitignore`);