@zokugun/artifact 0.1.0 → 0.2.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.
Files changed (45) hide show
  1. package/README.md +13 -6
  2. package/lib/cli.js +7 -2
  3. package/lib/commands/add.js +43 -9
  4. package/lib/commands/index.js +7 -0
  5. package/lib/commands/update.js +73 -0
  6. package/lib/compositors/compose.js +13 -5
  7. package/lib/compositors/index.js +3 -1
  8. package/lib/compositors/json.js +9 -5
  9. package/lib/compositors/map-sort.js +16 -0
  10. package/lib/compositors/rc.js +14 -4
  11. package/lib/compositors/yaml.js +8 -2
  12. package/lib/config/index.js +7 -0
  13. package/lib/{steps/read-target-config.js → config/read-config.js} +31 -14
  14. package/lib/config/write-config.js +44 -0
  15. package/lib/journeys/default/index.js +1 -1
  16. package/lib/journeys/fixpack/index.js +16 -0
  17. package/lib/journeys/index.js +7 -3
  18. package/lib/journeys/package/index.js +14 -14
  19. package/lib/journeys/rc/index.js +1 -1
  20. package/lib/journeys/tsconfig/index.js +20 -0
  21. package/lib/routes/command.js +30 -5
  22. package/lib/routes/index.js +5 -3
  23. package/lib/routes/lines-concat.js +1 -1
  24. package/lib/routes/list-sort-concat.js +42 -0
  25. package/lib/routes/{hash.js → map-concat.js} +3 -3
  26. package/lib/routes/overwrite.js +1 -1
  27. package/lib/routes/primitive.js +2 -2
  28. package/lib/steps/apply-formatting.js +1 -1
  29. package/lib/steps/copy-binary-files.js +12 -1
  30. package/lib/steps/index.js +29 -6
  31. package/lib/steps/merge-text-files.js +22 -7
  32. package/lib/steps/read-editor-config.js +6 -2
  33. package/lib/steps/read-files.js +10 -10
  34. package/lib/steps/read-incoming-config.js +20 -0
  35. package/lib/steps/read-incoming-package.js +3 -0
  36. package/lib/steps/validate-newer-package.js +25 -0
  37. package/lib/steps/validate-not-present-package.js +33 -0
  38. package/lib/steps/validate-updatability.js +160 -0
  39. package/lib/{utils/command → types}/command.js +0 -0
  40. package/lib/utils/command/join-command.js +6 -1
  41. package/lib/utils/dev-null.js +8 -0
  42. package/lib/utils/read-buffer.js +1 -1
  43. package/package.json +16 -8
  44. package/lib/install.js +0 -32
  45. package/lib/steps/update-target-config.js +0 -50
File without changes
@@ -17,7 +17,12 @@ function joinCommand(commands) {
17
17
  subcommand = `${subcommand} ${value.args.join(' ')}`;
18
18
  }
19
19
  if (value.separator) {
20
- subcommand = `${subcommand} ${value.separator}`;
20
+ if (value.separator === ';') {
21
+ subcommand += ';';
22
+ }
23
+ else {
24
+ subcommand = `${subcommand} ${value.separator}`;
25
+ }
21
26
  }
22
27
  subcommands.push(subcommand);
23
28
  }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDevNull = void 0;
4
+ const fs_1 = require("fs");
5
+ function createDevNull() {
6
+ return (0, fs_1.createWriteStream)('/dev/null');
7
+ }
8
+ exports.createDevNull = createDevNull;
@@ -13,8 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.readBuffer = void 0;
16
- const promises_1 = __importDefault(require("fs/promises"));
17
16
  const buffer_1 = require("buffer");
17
+ const promises_1 = __importDefault(require("fs/promises"));
18
18
  function readBuffer(filepath, size, offset = 0) {
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
20
  const buffer = buffer_1.Buffer.alloc(size);
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.1.0",
4
+ "version": "0.2.2",
5
5
  "author": {
6
6
  "name": "Baptiste Augrain",
7
7
  "email": "daiyam@zokugun.org"
@@ -33,7 +33,8 @@
33
33
  "watch:test": "tsc-watch -p test"
34
34
  },
35
35
  "dependencies": {
36
- "commander": "^8.2.0",
36
+ "ansi-colors": "^4.1.1",
37
+ "commander": "^9.0.0",
37
38
  "detect-indent": "^6.1.0",
38
39
  "editorconfig": "^0.15.3",
39
40
  "fs-extra": "^10.0.0",
@@ -41,29 +42,36 @@
41
42
  "istextorbinary": "^6.0.0",
42
43
  "jsonc-parser": "^3.0.0",
43
44
  "lodash": "^4.17.21",
45
+ "micromatch": "^4.0.4",
44
46
  "npm": "^7.23.0",
45
- "pacote": "^11.3.5",
46
- "tempy": "^1.0.1",
47
+ "ora": "^6.1.0",
48
+ "pacote": "^13.0.5",
49
+ "semver": "^7.3.5",
50
+ "tempy": "^2.0.0",
47
51
  "yaml": "^1.10.2"
48
52
  },
49
53
  "devDependencies": {
50
- "@commitlint/cli": "^13.1.0",
51
- "@commitlint/config-conventional": "^13.1.0",
54
+ "@commitlint/cli": "^16.2.3",
55
+ "@commitlint/config-conventional": "^16.2.1",
52
56
  "@types/chai": "^4.2.17",
57
+ "@types/chai-as-promised": "^7.1.4",
53
58
  "@types/fs-extra": "^9.0.12",
54
59
  "@types/lodash": "^4.14.172",
60
+ "@types/micromatch": "^4.0.2",
55
61
  "@types/mocha": "^9.0.0",
56
62
  "@types/node": "^14.17.15",
57
63
  "@types/npm": "^7.19.0",
58
64
  "@types/pacote": "^11.1.1",
65
+ "@types/semver": "^7.3.8",
59
66
  "@types/universalify": "^1.0.0",
60
67
  "camelcase": "^6.2.0",
61
68
  "chai": "^4.3.4",
69
+ "chai-as-promised": "^7.1.1",
62
70
  "commitizen": "^4.2.4",
63
71
  "eslint-plugin-chai-friendly": "^0.7.2",
64
72
  "fixpack": "^4.0.0",
65
73
  "husky": "^7.0.1",
66
- "lint-staged": "^11.1.1",
74
+ "lint-staged": "^12.3.6",
67
75
  "memfs": "^3.2.4",
68
76
  "mocha": "^9.1.1",
69
77
  "release-it": "^14.11.3",
@@ -72,7 +80,7 @@
72
80
  "tsc-watch": "^4.5.0",
73
81
  "typescript": "^4.2.4",
74
82
  "universalify": "^2.0.0",
75
- "xo": "^0.44.0"
83
+ "xo": "^0.48.0"
76
84
  },
77
85
  "keywords": [
78
86
  "artifact",
package/lib/install.js DELETED
@@ -1,32 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.install = void 0;
13
- const steps_1 = require("./steps");
14
- const commonFlow = (0, steps_1.composeSteps)(steps_1.steps.readTargetConfig, steps_1.steps.readIncomingPackage, steps_1.steps.readFiles, steps_1.steps.readEditorConfig, steps_1.steps.mergeTextFiles, steps_1.steps.updateTargetConfig, steps_1.steps.insertFinalNewLine, steps_1.steps.applyFormatting, steps_1.steps.copyBinaryFiles, steps_1.steps.writeTextFiles);
15
- function install(targetPath, incomingPath, options) {
16
- var _a;
17
- return __awaiter(this, void 0, void 0, function* () {
18
- yield commonFlow({
19
- targetPath,
20
- incomingPath,
21
- binaryFiles: [],
22
- textFiles: [],
23
- mergedTextFiles: [],
24
- configs: [],
25
- formats: [],
26
- options: {
27
- verbose: (_a = options === null || options === void 0 ? void 0 : options.verbose) !== null && _a !== void 0 ? _a : false,
28
- },
29
- });
30
- });
31
- }
32
- exports.install = install;
@@ -1,50 +0,0 @@
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.updateTargetConfig = void 0;
16
- const yaml_1 = __importDefault(require("yaml"));
17
- function updateTargetConfig({ configs, configInfo, incomingPackage, mergedTextFiles }) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- const name = incomingPackage.name;
20
- const version = incomingPackage.version;
21
- let nf = true;
22
- for (const config of configs) {
23
- if (config.name === name) {
24
- config.version = version;
25
- nf = false;
26
- break;
27
- }
28
- }
29
- if (nf) {
30
- configs.push({
31
- name,
32
- version,
33
- });
34
- }
35
- if (!configInfo) {
36
- configInfo = {
37
- name: '.artifactrc.yml',
38
- type: 'yaml',
39
- finalNewLine: true,
40
- };
41
- }
42
- const data = configInfo.type === 'yaml' ? yaml_1.default.stringify(configs) : JSON.stringify(configs, null, '\t');
43
- mergedTextFiles.push({
44
- name: configInfo.name,
45
- data,
46
- finalNewLine: configInfo.finalNewLine,
47
- });
48
- });
49
- }
50
- exports.updateTargetConfig = updateTargetConfig;