@zokugun/artifact 0.3.1 → 0.4.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.
Files changed (66) hide show
  1. package/README.md +122 -37
  2. package/lib/cli.js +8 -2
  3. package/lib/commands/add.js +37 -44
  4. package/lib/commands/index.js +3 -1
  5. package/lib/commands/list.js +46 -0
  6. package/lib/commands/update.js +34 -20
  7. package/lib/compositors/compose.js +7 -12
  8. package/lib/compositors/fork.js +1 -2
  9. package/lib/compositors/json.js +18 -9
  10. package/lib/compositors/map-sort.js +1 -2
  11. package/lib/compositors/rc.js +18 -9
  12. package/lib/compositors/yaml.js +18 -9
  13. package/lib/configs/index.js +18 -0
  14. package/lib/configs/install/index.js +9 -0
  15. package/lib/configs/install/read-install-config.js +120 -0
  16. package/lib/configs/install/update-install-config.js +15 -0
  17. package/lib/{config/write-config.js → configs/install/write-install-config.js} +8 -9
  18. package/lib/configs/package/index.js +5 -0
  19. package/lib/{config/read-config.js → configs/package/read-package-config.js} +14 -32
  20. package/lib/journeys/config.ts/index.js +11 -0
  21. package/lib/journeys/index.js +3 -2
  22. package/lib/journeys/package/index.js +0 -1
  23. package/lib/parsers/json.js +2 -3
  24. package/lib/parsers/jsonc/parse.js +2 -3
  25. package/lib/parsers/jsonc/stringify.js +1 -2
  26. package/lib/parsers/yaml.js +2 -3
  27. package/lib/routes/command.js +1 -2
  28. package/lib/routes/lines-concat.js +1 -2
  29. package/lib/routes/list-concat.js +1 -2
  30. package/lib/routes/list-sort-concat.js +1 -2
  31. package/lib/routes/map-concat.js +1 -2
  32. package/lib/routes/overwrite.js +1 -2
  33. package/lib/routes/primitive.js +1 -2
  34. package/lib/steps/apply-formatting.js +5 -6
  35. package/lib/steps/configure-branches.js +69 -0
  36. package/lib/steps/configure-install-file-actions.js +151 -0
  37. package/lib/steps/{validate-updatability.js → configure-update-file-actions.js} +9 -10
  38. package/lib/steps/copy-binary-files.js +21 -13
  39. package/lib/steps/execute-first-block.js +112 -0
  40. package/lib/steps/execute-next-block.js +22 -0
  41. package/lib/steps/index.js +47 -9
  42. package/lib/steps/insert-final-new-line.js +3 -4
  43. package/lib/steps/merge-text-files.js +65 -36
  44. package/lib/steps/read-editor-config.js +22 -13
  45. package/lib/steps/read-files.js +3 -4
  46. package/lib/steps/read-incoming-config.js +9 -5
  47. package/lib/steps/read-incoming-package.js +12 -4
  48. package/lib/steps/remove-files.js +40 -0
  49. package/lib/steps/replace-templates.js +3 -4
  50. package/lib/steps/validate-newer-package.js +4 -5
  51. package/lib/steps/validate-not-present-package.js +4 -5
  52. package/lib/steps/write-text-files.js +3 -4
  53. package/lib/types/format.js +1 -1
  54. package/lib/utils/build-journey-plan.js +1 -2
  55. package/lib/utils/build-travel-plan.js +1 -2
  56. package/lib/utils/command/join-command.js +1 -2
  57. package/lib/utils/command/split-command.js +1 -2
  58. package/lib/utils/dev-null.js +1 -2
  59. package/lib/utils/read-buffer.js +5 -8
  60. package/lib/utils/resolve-request.js +42 -0
  61. package/lib/utils/template.js +21 -10
  62. package/lib/utils/to-lines.js +1 -2
  63. package/lib/utils/trim-final-newline.js +1 -2
  64. package/lib/utils/try-json.js +1 -2
  65. package/package.json +6 -4
  66. package/lib/config/index.js +0 -7
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,7 +45,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
45
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
46
  };
37
47
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.readEditorConfig = void 0;
48
+ exports.readEditorConfig = readEditorConfig;
39
49
  const path_1 = __importDefault(require("path"));
40
50
  const editorconfig = __importStar(require("editorconfig"));
41
51
  const fs_extra_1 = __importDefault(require("fs-extra"));
@@ -53,22 +63,22 @@ function buildFullGlob(glob) {
53
63
  }
54
64
  return glob.replace(/\*\*/g, '{*,**/**/**}');
55
65
  } // }}}
56
- function readEditorConfig({ incomingPath, targetPath, formats }) {
57
- return __awaiter(this, void 0, void 0, function* () {
66
+ function readEditorConfig(_a) {
67
+ return __awaiter(this, arguments, void 0, function* ({ incomingPath, targetPath, formats }) {
58
68
  let data;
59
69
  try {
60
70
  const dir = path_1.default.join(incomingPath, 'configs');
61
71
  const file = path_1.default.join(dir, '.editorconfig');
62
72
  data = yield fs_extra_1.default.readFile(file, 'utf-8');
63
73
  }
64
- catch (_a) {
74
+ catch (_b) {
65
75
  }
66
76
  if (!data) {
67
77
  try {
68
78
  const file = path_1.default.join(targetPath, '.editorconfig');
69
79
  data = yield fs_extra_1.default.readFile(file, 'utf-8');
70
80
  }
71
- catch (_b) {
81
+ catch (_c) {
72
82
  }
73
83
  }
74
84
  if (!data) {
@@ -98,4 +108,3 @@ function readEditorConfig({ incomingPath, targetPath, formats }) {
98
108
  formats.reverse();
99
109
  });
100
110
  }
101
- exports.readEditorConfig = readEditorConfig;
@@ -12,14 +12,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.readFiles = void 0;
15
+ exports.readFiles = readFiles;
16
16
  const path_1 = __importDefault(require("path"));
17
17
  const fs_extra_1 = __importDefault(require("fs-extra"));
18
18
  const globby_1 = __importDefault(require("globby"));
19
19
  const istextorbinary_1 = require("istextorbinary");
20
20
  const read_buffer_1 = require("../utils/read-buffer");
21
- function readFiles({ incomingPath, textFiles, binaryFiles, options }) {
22
- return __awaiter(this, void 0, void 0, function* () {
21
+ function readFiles(_a) {
22
+ return __awaiter(this, arguments, void 0, function* ({ incomingPath, textFiles, binaryFiles, options }) {
23
23
  const cwd = path_1.default.join(incomingPath, 'configs');
24
24
  const files = yield (0, globby_1.default)(['**/*', '!**/*.lock', '!**/*-lock.*'], {
25
25
  cwd,
@@ -66,4 +66,3 @@ function readFiles({ incomingPath, textFiles, binaryFiles, options }) {
66
66
  }
67
67
  });
68
68
  }
69
- exports.readFiles = readFiles;
@@ -9,12 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.readIncomingConfig = void 0;
13
- const config_1 = require("../config");
12
+ exports.readIncomingConfig = readIncomingConfig;
13
+ const configs_1 = require("../configs");
14
14
  function readIncomingConfig(context) {
15
15
  return __awaiter(this, void 0, void 0, function* () {
16
- const [config] = yield (0, config_1.readConfig)(context.incomingPath);
17
- context.incomingConfig = config;
16
+ if (!context.incomingConfig) {
17
+ const config = yield (0, configs_1.readPackageConfig)(context.incomingPath);
18
+ if (!config) {
19
+ return true;
20
+ }
21
+ context.incomingConfig = config;
22
+ }
18
23
  });
19
24
  }
20
- exports.readIncomingConfig = readIncomingConfig;
@@ -12,16 +12,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.readIncomingPackage = void 0;
15
+ exports.readIncomingPackage = readIncomingPackage;
16
16
  const path_1 = __importDefault(require("path"));
17
17
  const fs_extra_1 = __importDefault(require("fs-extra"));
18
+ const lodash_1 = require("lodash");
18
19
  function readIncomingPackage(context) {
19
20
  return __awaiter(this, void 0, void 0, function* () {
20
21
  const filePath = path_1.default.resolve(context.incomingPath, './package.json');
21
- context.incomingPackage = (yield fs_extra_1.default.readJSON(filePath));
22
- if (!context.incomingPackage) {
22
+ const incomingPackage = yield fs_extra_1.default.readJSON(filePath);
23
+ if (!isPackageManifest(incomingPackage)) {
23
24
  throw new Error('The package of the incoming artifact can\'t be found.');
24
25
  }
26
+ context.incomingPackage = incomingPackage;
25
27
  });
26
28
  }
27
- exports.readIncomingPackage = readIncomingPackage;
29
+ function isPackageManifest(value) {
30
+ if ((0, lodash_1.isNil)(value) || !(0, lodash_1.isPlainObject)(value)) {
31
+ return false;
32
+ }
33
+ const manifest = value;
34
+ return typeof manifest.name === 'string' && typeof manifest.version === 'string';
35
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.removeFiles = removeFiles;
16
+ const path_1 = __importDefault(require("path"));
17
+ const fs_extra_1 = __importDefault(require("fs-extra"));
18
+ const globby_1 = __importDefault(require("globby"));
19
+ const micromatch_1 = require("micromatch");
20
+ function removeFiles(_a) {
21
+ return __awaiter(this, arguments, void 0, function* ({ removedPatterns, targetPath, options }) {
22
+ if (removedPatterns.length === 0) {
23
+ return;
24
+ }
25
+ const cwd = path_1.default.join(targetPath);
26
+ const files = yield (0, globby_1.default)(['**/*', '!**/*.lock', '!**/*-lock.*', '!.git'], {
27
+ cwd,
28
+ dot: true,
29
+ });
30
+ for (const file of files) {
31
+ if ((0, micromatch_1.isMatch)(file, removedPatterns)) {
32
+ const filePath = path_1.default.join(cwd, file);
33
+ yield fs_extra_1.default.unlink(filePath);
34
+ if (options.verbose) {
35
+ console.log(`${file} has been removed`);
36
+ }
37
+ }
38
+ }
39
+ });
40
+ }
@@ -9,10 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.replaceTemplates = void 0;
12
+ exports.replaceTemplates = replaceTemplates;
13
13
  const template_1 = require("../utils/template");
14
- function replaceTemplates({ textFiles, binaryFiles, targetPath }) {
15
- return __awaiter(this, void 0, void 0, function* () {
14
+ function replaceTemplates(_a) {
15
+ return __awaiter(this, arguments, void 0, function* ({ textFiles, binaryFiles, targetPath }) {
16
16
  const engine = new template_1.TemplateEngine(targetPath);
17
17
  for (const file of textFiles) {
18
18
  file.data = engine.render(file.data);
@@ -23,4 +23,3 @@ function replaceTemplates({ textFiles, binaryFiles, targetPath }) {
23
23
  }
24
24
  });
25
25
  }
26
- exports.replaceTemplates = replaceTemplates;
@@ -9,17 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.validateNewerPackage = void 0;
12
+ exports.validateNewerPackage = validateNewerPackage;
13
13
  const semver_1 = require("semver");
14
- function validateNewerPackage({ incomingPackage, config, options }) {
15
- return __awaiter(this, void 0, void 0, function* () {
14
+ function validateNewerPackage(_a) {
15
+ return __awaiter(this, arguments, void 0, function* ({ incomingPackage, config, options }) {
16
16
  if (options.force) {
17
17
  return;
18
18
  }
19
- const artifact = config.artifacts.find(({ name }) => name === incomingPackage.name);
19
+ const artifact = config.artifacts[incomingPackage.name];
20
20
  if (artifact) {
21
21
  return !(0, semver_1.gt)(incomingPackage.version, artifact.version);
22
22
  }
23
23
  });
24
24
  }
25
- exports.validateNewerPackage = validateNewerPackage;
@@ -9,14 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.validateNotPresentPackage = void 0;
13
- function validateNotPresentPackage({ incomingPackage, config, options }) {
14
- return __awaiter(this, void 0, void 0, function* () {
12
+ exports.validateNotPresentPackage = validateNotPresentPackage;
13
+ function validateNotPresentPackage(_a) {
14
+ return __awaiter(this, arguments, void 0, function* ({ incomingPackage, config, options }) {
15
15
  if (options.force) {
16
16
  return;
17
17
  }
18
18
  const { name } = incomingPackage;
19
- const artifact = config.artifacts.find((artifact) => artifact.name === name);
19
+ const artifact = config.artifacts[name];
20
20
  if (artifact) {
21
21
  if (options.skip) {
22
22
  if (options.verbose) {
@@ -30,4 +30,3 @@ function validateNotPresentPackage({ incomingPackage, config, options }) {
30
30
  }
31
31
  });
32
32
  }
33
- exports.validateNotPresentPackage = validateNotPresentPackage;
@@ -12,11 +12,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.writeTextFiles = void 0;
15
+ exports.writeTextFiles = writeTextFiles;
16
16
  const path_1 = __importDefault(require("path"));
17
17
  const fs_extra_1 = __importDefault(require("fs-extra"));
18
- function writeTextFiles({ mergedTextFiles, targetPath, options }) {
19
- return __awaiter(this, void 0, void 0, function* () {
18
+ function writeTextFiles(_a) {
19
+ return __awaiter(this, arguments, void 0, function* ({ mergedTextFiles, targetPath, options }) {
20
20
  for (const file of mergedTextFiles) {
21
21
  const filePath = path_1.default.join(targetPath, file.name);
22
22
  yield fs_extra_1.default.outputFile(filePath, file.data, 'utf-8');
@@ -29,4 +29,3 @@ function writeTextFiles({ mergedTextFiles, targetPath, options }) {
29
29
  }
30
30
  });
31
31
  }
32
- exports.writeTextFiles = writeTextFiles;
@@ -5,4 +5,4 @@ var IndentStyle;
5
5
  (function (IndentStyle) {
6
6
  IndentStyle["SPACE"] = "space";
7
7
  IndentStyle["TAB"] = "tab";
8
- })(IndentStyle = exports.IndentStyle || (exports.IndentStyle = {}));
8
+ })(IndentStyle || (exports.IndentStyle = IndentStyle = {}));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildJourneyPlan = void 0;
3
+ exports.buildJourneyPlan = buildJourneyPlan;
4
4
  function buildJourneyPlan(plan, alias) {
5
5
  return (basename) => {
6
6
  const travel = plan(basename);
@@ -15,4 +15,3 @@ function buildJourneyPlan(plan, alias) {
15
15
  }
16
16
  };
17
17
  }
18
- exports.buildJourneyPlan = buildJourneyPlan;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildTravelPlan = void 0;
3
+ exports.buildTravelPlan = buildTravelPlan;
4
4
  function buildTravelPlan(...mappers) {
5
5
  return (basename) => {
6
6
  const mapper = mappers.find((mapper) => {
@@ -17,4 +17,3 @@ function buildTravelPlan(...mappers) {
17
17
  }
18
18
  };
19
19
  }
20
- exports.buildTravelPlan = buildTravelPlan;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.joinCommand = void 0;
3
+ exports.joinCommand = joinCommand;
4
4
  function joinCommand(commands) {
5
5
  const subcommands = [];
6
6
  for (const [key, values] of Object.entries(commands)) {
@@ -29,4 +29,3 @@ function joinCommand(commands) {
29
29
  }
30
30
  return subcommands.join(' ');
31
31
  }
32
- exports.joinCommand = joinCommand;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.splitCommand = void 0;
3
+ exports.splitCommand = splitCommand;
4
4
  const lodash_1 = require("lodash");
5
5
  function splitCommand(command) {
6
6
  const result = {};
@@ -29,4 +29,3 @@ function splitCommand(command) {
29
29
  }
30
30
  return result;
31
31
  }
32
- exports.splitCommand = splitCommand;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDevNull = void 0;
3
+ exports.createDevNull = createDevNull;
4
4
  const fs_1 = require("fs");
5
5
  function createDevNull() {
6
6
  return (0, fs_1.createWriteStream)('/dev/null');
7
7
  }
8
- exports.createDevNull = createDevNull;
@@ -12,19 +12,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.readBuffer = void 0;
15
+ exports.readBuffer = readBuffer;
16
16
  const buffer_1 = require("buffer");
17
17
  const promises_1 = __importDefault(require("fs/promises"));
18
- function readBuffer(filepath, size, offset = 0) {
19
- return __awaiter(this, void 0, void 0, function* () {
18
+ function readBuffer(filepath_1, size_1) {
19
+ return __awaiter(this, arguments, void 0, function* (filepath, size, offset = 0) {
20
20
  const buffer = buffer_1.Buffer.alloc(size);
21
21
  const file = yield promises_1.default.open(filepath, 'r');
22
22
  try {
23
- const { bytesRead } = yield file.read(buffer, offset, size, 0);
23
+ const { bytesRead } = yield file.read(buffer, 0, size, offset);
24
24
  if (bytesRead < size) {
25
- const smaller = buffer_1.Buffer.alloc(bytesRead);
26
- buffer.copy(smaller, 0, 0, bytesRead);
27
- return smaller;
25
+ return buffer.slice(0, bytesRead);
28
26
  }
29
27
  else {
30
28
  return buffer;
@@ -35,4 +33,3 @@ function readBuffer(filepath, size, offset = 0) {
35
33
  }
36
34
  });
37
35
  }
38
- exports.readBuffer = readBuffer;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolveRequest = resolveRequest;
7
+ const untildify_1 = __importDefault(require("untildify"));
8
+ function resolveRequest(spec) {
9
+ if (spec.startsWith('~')) {
10
+ spec = (0, untildify_1.default)(spec);
11
+ }
12
+ else if (spec.startsWith('/')) {
13
+ // skip
14
+ }
15
+ else if (spec.includes('/')) {
16
+ const [scope, name] = spec.split('/');
17
+ if (name.startsWith('artifact-')) {
18
+ // skip
19
+ }
20
+ else {
21
+ spec = `${scope}/artifact-${name}`;
22
+ }
23
+ }
24
+ else {
25
+ if (spec.startsWith('artifact-')) {
26
+ // skip
27
+ }
28
+ else {
29
+ spec = `artifact-${spec}`;
30
+ }
31
+ }
32
+ if (spec.includes(':')) {
33
+ const [name, variant] = spec.split(':');
34
+ if (variant.length === 0) {
35
+ throw new Error(`Missing variant in "${spec}"`);
36
+ }
37
+ return { name, variant };
38
+ }
39
+ else {
40
+ return { name: spec };
41
+ }
42
+ } // }}}
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
@@ -31,6 +41,7 @@ const path_1 = __importDefault(require("path"));
31
41
  const dayjs_1 = __importDefault(require("dayjs"));
32
42
  const utc_1 = __importDefault(require("dayjs/plugin/utc"));
33
43
  const fs_extra_1 = __importDefault(require("fs-extra"));
44
+ const lodash_1 = require("lodash");
34
45
  const YAML = __importStar(require("../parsers/yaml"));
35
46
  const try_json_1 = require("./try-json");
36
47
  dayjs_1.default.extend(utc_1.default);
@@ -58,7 +69,7 @@ class TemplateEngine {
58
69
  }
59
70
  const fileContent = this.readConfigFile(name);
60
71
  const value = this.getValueByPath(fileContent, propertyPath);
61
- if (value === null || value === undefined) {
72
+ if ((0, lodash_1.isNil)(value)) {
62
73
  throw new TemplateError(placeholder);
63
74
  }
64
75
  return String(value);
@@ -68,12 +79,12 @@ class TemplateEngine {
68
79
  const parts = propertyPath.split('.');
69
80
  let current = values;
70
81
  for (const part of parts) {
71
- if (current === null || current === undefined || typeof current !== 'object') {
82
+ if (!(0, lodash_1.isPlainObject)(current)) {
72
83
  throw new TemplateError(`Property path not found: ${propertyPath}`);
73
84
  }
74
85
  current = current[part];
75
86
  }
76
- if (current === null || current === undefined) {
87
+ if ((0, lodash_1.isNil)(current)) {
77
88
  throw new TemplateError(`Property not found: ${propertyPath}`);
78
89
  }
79
90
  return current;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toLines = void 0;
3
+ exports.toLines = toLines;
4
4
  function toLines(value) {
5
5
  return value.split(/\r?\n/g);
6
6
  }
7
- exports.toLines = toLines;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.trimFinalNewLine = void 0;
3
+ exports.trimFinalNewLine = trimFinalNewLine;
4
4
  const FINAL_NEWLINE_REGEX = /(\r?\n)*$/;
5
5
  function trimFinalNewLine(value) {
6
6
  return value.replace(FINAL_NEWLINE_REGEX, '');
7
7
  }
8
- exports.trimFinalNewLine = trimFinalNewLine;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tryJson = void 0;
3
+ exports.tryJson = tryJson;
4
4
  function tryJson(value) {
5
5
  try {
6
6
  return JSON.parse(value);
@@ -9,4 +9,3 @@ function tryJson(value) {
9
9
  return undefined;
10
10
  }
11
11
  }
12
- exports.tryJson = tryJson;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zokugun/artifact",
3
3
  "description": "Boilerplate your project & keep your configurations up to date",
4
- "version": "0.3.1",
4
+ "version": "0.4.1",
5
5
  "author": {
6
6
  "name": "Baptiste Augrain",
7
7
  "email": "daiyam@zokugun.org"
@@ -28,12 +28,12 @@
28
28
  "release": "release-it",
29
29
  "test": "tsc -p test && mocha",
30
30
  "test:dev": "mocha",
31
- "test:watch": "tsc-watch -p test --onSuccess 'mocha'",
32
- "watch": "tsc-watch -p src",
31
+ "test:watch": "tsc-watch -p src -p test --onSuccess 'mocha'",
33
32
  "watch:src": "tsc-watch -p src",
34
33
  "watch:test": "tsc-watch -p test"
35
34
  },
36
35
  "dependencies": {
36
+ "@zokugun/configdotts-merge": "^0.2.0",
37
37
  "ansi-colors": "^4.1.1",
38
38
  "commander": "^9.0.0",
39
39
  "dayjs": "^1.11.13",
@@ -50,6 +50,8 @@
50
50
  "pacote": "^13.0.5",
51
51
  "semver": "^7.3.5",
52
52
  "tempy": "^1.0.1",
53
+ "typescript": "^5.9.2",
54
+ "untildify": "^4.0.0",
53
55
  "yaml": "^1.10.2"
54
56
  },
55
57
  "devDependencies": {
@@ -70,6 +72,7 @@
70
72
  "chai": "^4.3.4",
71
73
  "chai-as-promised": "^7.1.1",
72
74
  "commitizen": "^4.2.4",
75
+ "eslint": "8.11.0",
73
76
  "eslint-plugin-chai-friendly": "^0.7.2",
74
77
  "fixpack": "^4.0.0",
75
78
  "husky": "^7.0.1",
@@ -80,7 +83,6 @@
80
83
  "rewiremock": "^3.14.3",
81
84
  "source-map-support": "^0.5.20",
82
85
  "tsc-watch": "^4.5.0",
83
- "typescript": "^4.2.4",
84
86
  "universalify": "^2.0.0",
85
87
  "xo": "^0.48.0"
86
88
  },
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeConfig = exports.readConfig = void 0;
4
- var read_config_1 = require("./read-config");
5
- Object.defineProperty(exports, "readConfig", { enumerable: true, get: function () { return read_config_1.readConfig; } });
6
- var write_config_1 = require("./write-config");
7
- Object.defineProperty(exports, "writeConfig", { enumerable: true, get: function () { return write_config_1.writeConfig; } });