@zokugun/artifact 0.6.0 → 0.6.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 (31) hide show
  1. package/lib/configs/install/read-install-config.js +9 -5
  2. package/lib/configs/install/write-install-config.d.ts +1 -1
  3. package/lib/configs/install/write-install-config.js +10 -3
  4. package/lib/configs/package/read-package-config.js +52 -51
  5. package/lib/configs/utils/merge-upsert-property.d.ts +2 -2
  6. package/lib/configs/utils/merge-upsert-property.js +28 -18
  7. package/lib/configs/utils/normalize-file-always.d.ts +2 -2
  8. package/lib/configs/utils/normalize-file-always.js +2 -1
  9. package/lib/configs/utils/normalize-file-uninstall.d.ts +2 -2
  10. package/lib/configs/utils/normalize-file-uninstall.js +2 -1
  11. package/lib/configs/utils/normalize-file-upsert.d.ts +2 -2
  12. package/lib/configs/utils/normalize-file-upsert.js +2 -1
  13. package/lib/steps/apply-formatting.d.ts +1 -1
  14. package/lib/steps/apply-formatting.js +35 -14
  15. package/lib/steps/configure-install-file-actions.js +23 -13
  16. package/lib/steps/configure-uninstall-file-actions.js +11 -7
  17. package/lib/steps/configure-update-file-actions.js +18 -22
  18. package/lib/steps/insert-final-new-line.d.ts +1 -1
  19. package/lib/steps/merge-text-files.js +6 -1
  20. package/lib/steps/read-files.js +7 -2
  21. package/lib/steps/transform-untouched-files.js +4 -13
  22. package/lib/steps/unmerge-text-files.js +1 -0
  23. package/lib/types/config.d.ts +15 -14
  24. package/lib/types/context.d.ts +8 -2
  25. package/lib/types/context.js +4 -0
  26. package/lib/types/format.d.ts +4 -0
  27. package/lib/utils/detect-indent.d.ts +2 -5
  28. package/lib/utils/detect-indent.js +3 -0
  29. package/package.json +124 -123
  30. package/lib/types/text-file.d.ts +0 -7
  31. package/lib/types/text-file.js +0 -2
@@ -9,6 +9,8 @@ const async_1 = __importDefault(require("@zokugun/fs-extra-plus/async"));
9
9
  const is_it_type_1 = require("@zokugun/is-it-type");
10
10
  const xtry_1 = require("@zokugun/xtry");
11
11
  const yaml_1 = __importDefault(require("yaml"));
12
+ const detect_indent_js_1 = require("../../utils/detect-indent.js");
13
+ const has_final_new_line_js_1 = require("../../utils/has-final-new-line.js");
12
14
  const constants_js_1 = require("../utils/constants.js");
13
15
  const normalize_file_upsert_js_1 = require("../utils/normalize-file-upsert.js");
14
16
  async function readInstallConfig(targetPath) {
@@ -29,12 +31,14 @@ async function readInstallConfig(targetPath) {
29
31
  finalNewLine: true,
30
32
  });
31
33
  }
32
- const finalNewLine = content.endsWith('\n');
34
+ const finalNewLine = (0, has_final_new_line_js_1.hasFinalNewLine)(content);
35
+ const indent = (0, detect_indent_js_1.detectIndent)(content);
33
36
  if (type === 'json') {
34
37
  return normalizeConfig(JSON.parse(content), {
35
38
  name,
36
39
  type: 'json',
37
40
  finalNewLine,
41
+ indent,
38
42
  });
39
43
  }
40
44
  else if (type === 'yaml') {
@@ -42,6 +46,7 @@ async function readInstallConfig(targetPath) {
42
46
  name,
43
47
  type: 'yaml',
44
48
  finalNewLine,
49
+ indent,
45
50
  });
46
51
  }
47
52
  else {
@@ -50,6 +55,7 @@ async function readInstallConfig(targetPath) {
50
55
  name,
51
56
  type: 'json',
52
57
  finalNewLine,
58
+ indent,
53
59
  });
54
60
  }
55
61
  catch {
@@ -57,6 +63,7 @@ async function readInstallConfig(targetPath) {
57
63
  name,
58
64
  type: 'yaml',
59
65
  finalNewLine,
66
+ indent,
60
67
  });
61
68
  }
62
69
  }
@@ -129,13 +136,10 @@ function normalizeConfig(data, configStats) {
129
136
  }
130
137
  else if ((0, is_it_type_1.isRecord)(data.update)) {
131
138
  for (const [key, value] of Object.entries(data.update)) {
132
- const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(value, 'update');
139
+ const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(key, value, 'update');
133
140
  if (normalized.fails) {
134
141
  return normalized;
135
142
  }
136
- if (update[key]) {
137
- return (0, xtry_1.err)(`Conflict with the "${key}" key on "update"1.`);
138
- }
139
143
  update[key] = normalized.value;
140
144
  }
141
145
  }
@@ -2,4 +2,4 @@ import { type AsyncDResult } from '@zokugun/xtry';
2
2
  import { type InstallConfig, type InstallConfigStats } from '../../types/config.js';
3
3
  import { type Options } from '../../types/context.js';
4
4
  import { type Format } from '../../types/format.js';
5
- export declare function writeInstallConfig(config: InstallConfig, { name, finalNewLine, type }: InstallConfigStats, formats: Format[], targetPath: string, options: Options): AsyncDResult;
5
+ export declare function writeInstallConfig(config: InstallConfig, { name, finalNewLine, indent, type }: InstallConfigStats, formats: Format[], targetPath: string, options: Options): AsyncDResult;
@@ -7,23 +7,30 @@ exports.writeInstallConfig = writeInstallConfig;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const cli_utils_1 = require("@zokugun/cli-utils");
9
9
  const async_1 = __importDefault(require("@zokugun/fs-extra-plus/async"));
10
+ const is_it_type_1 = require("@zokugun/is-it-type");
10
11
  const xtry_1 = require("@zokugun/xtry");
11
- const lodash_es_1 = require("lodash-es");
12
12
  const yaml_1 = __importDefault(require("yaml"));
13
13
  const apply_formatting_js_1 = require("../../steps/apply-formatting.js");
14
14
  const insert_final_new_line_js_1 = require("../../steps/insert-final-new-line.js");
15
15
  const constants_js_1 = require("../utils/constants.js");
16
- async function writeInstallConfig(config, { name, finalNewLine, type }, formats, targetPath, options) {
16
+ async function writeInstallConfig(config, { name, finalNewLine, indent, type }, formats, targetPath, options) {
17
17
  const exported = {
18
18
  $schema: `https://raw.githubusercontent.com/zokugun/artifact/v${constants_js_1.VERSION_RELEASE}/schemas/v${constants_js_1.MAX_VERSION}/install.json`,
19
19
  artifacts: config.artifacts,
20
20
  };
21
- if (!(0, lodash_es_1.isPlainObject)(config.update) || !(0, lodash_es_1.isEmpty)(config.update)) {
21
+ if ((0, is_it_type_1.isNonEmptyRecord)(config.update)) {
22
22
  exported.update = config.update;
23
23
  }
24
+ if ((0, is_it_type_1.isNonEmptyRecord)(config.constants)) {
25
+ exported.constants = config.constants;
26
+ }
27
+ if ((0, is_it_type_1.isNonEmptyRecord)(config.variables)) {
28
+ exported.variables = config.variables;
29
+ }
24
30
  const file = {
25
31
  name,
26
32
  data: type === 'yaml' ? yaml_1.default.stringify(exported) : JSON.stringify(exported, null, '\t'),
33
+ indent,
27
34
  finalNewLine,
28
35
  };
29
36
  await (0, insert_final_new_line_js_1.insertFinalNewLine)({ mergedTextFiles: [file] });
@@ -46,10 +46,10 @@ async function readPackageConfig(targetPath) {
46
46
  function normalizeConfig(data, source) {
47
47
  let constants = {};
48
48
  let xtends;
49
- const install = {};
49
+ const install = [];
50
50
  let orphan = false;
51
- const uninstall = {};
52
- let update = {};
51
+ const uninstall = [];
52
+ let update = [];
53
53
  let variables = {};
54
54
  let variants = {};
55
55
  if (!data) {
@@ -95,81 +95,82 @@ function normalizeConfig(data, source) {
95
95
  if ((0, is_it_type_1.isRecord)(data.variants, (_key, value) => (0, is_it_type_1.isString)(value) || (0, is_it_type_1.isNumber)(value))) {
96
96
  variants = Object.fromEntries(Object.entries(data.variants).map(([key, value]) => [key, (0, is_it_type_1.isNumber)(value) ? String(value) : value]));
97
97
  }
98
- if ((0, is_it_type_1.isRecord)(data.always)) {
99
- for (const [key, value] of Object.entries(data.always)) {
100
- const normalized = (0, normalize_file_always_js_1.normalizeFileAlways)(value);
98
+ if ((0, is_it_type_1.isRecord)(data.install)) {
99
+ for (const [key, value] of Object.entries(data.install)) {
100
+ const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(key, value, 'install');
101
101
  if (normalized.fails) {
102
102
  return normalized;
103
103
  }
104
- const { ifExists, transforms } = normalized.value;
105
- install[key] = {
106
- ...normalized.value,
107
- ifMissing: 'merge',
108
- };
109
- uninstall[key] = {
110
- ifExists: ifExists === 'force-merge' || ifExists === 'merge' || ifExists === 'overwrite' ? 'skip' : ifExists,
111
- transforms,
112
- };
113
- update[key] = {
114
- ...normalized.value,
115
- ifMissing: 'merge',
116
- };
104
+ install.push(normalized.value);
117
105
  }
118
106
  }
119
- if ((0, is_it_type_1.isRecord)(data.upsert)) {
120
- for (const [key, value] of Object.entries(data.upsert)) {
121
- const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(value, 'upsert');
107
+ if (data.update === false) {
108
+ update = false;
109
+ }
110
+ else if ((0, is_it_type_1.isRecord)(data.update)) {
111
+ for (const [key, value] of Object.entries(data.update)) {
112
+ const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(key, value, 'update');
122
113
  if (normalized.fails) {
123
114
  return normalized;
124
115
  }
125
- install[key] = normalized.value;
126
- update[key] = {
127
- ...normalized.value,
128
- };
116
+ update.push(normalized.value);
129
117
  }
130
118
  }
131
- if ((0, is_it_type_1.isRecord)(data.install)) {
132
- for (const [key, value] of Object.entries(data.install)) {
133
- const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(value, 'install');
119
+ if ((0, is_it_type_1.isRecord)(data.uninstall)) {
120
+ for (const [key, value] of Object.entries(data.uninstall)) {
121
+ const normalized = (0, normalize_file_uninstall_js_1.normalizeFileUninstall)(key, value);
134
122
  if (normalized.fails) {
135
123
  return normalized;
136
124
  }
137
- if (install[key]) {
138
- const result = (0, merge_upsert_property_js_1.mergeUpsertProperty)(key, update[key], normalized.value);
139
- if (result.fails) {
140
- return result;
141
- }
142
- }
143
- install[key] = normalized.value;
125
+ uninstall.push(normalized.value);
144
126
  }
145
127
  }
146
- if ((0, is_it_type_1.isRecord)(data.uninstall)) {
147
- for (const [key, value] of Object.entries(data.uninstall)) {
148
- const normalized = (0, normalize_file_uninstall_js_1.normalizeFileUninstall)(value);
128
+ if ((0, is_it_type_1.isRecord)(data.upsert)) {
129
+ for (const [key, value] of Object.entries(data.upsert)) {
130
+ const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(key, value, 'upsert');
149
131
  if (normalized.fails) {
150
132
  return normalized;
151
133
  }
152
- uninstall[key] = normalized.value;
134
+ const result = (0, merge_upsert_property_js_1.mergeUpsertProperty)(normalized.value, install);
135
+ if (result.fails) {
136
+ return result;
137
+ }
138
+ if (update) {
139
+ const result = (0, merge_upsert_property_js_1.mergeUpsertProperty)(normalized.value, update);
140
+ if (result.fails) {
141
+ return result;
142
+ }
143
+ }
153
144
  }
154
145
  }
155
- if (data.update === false) {
156
- update = false;
157
- }
158
- else if ((0, is_it_type_1.isRecord)(data.update)) {
159
- for (const [key, value] of Object.entries(data.update)) {
160
- const normalized = (0, normalize_file_upsert_js_1.normalizeFileUpsert)(value, 'update');
146
+ if ((0, is_it_type_1.isRecord)(data.always)) {
147
+ for (const [key, value] of Object.entries(data.always)) {
148
+ const normalized = (0, normalize_file_always_js_1.normalizeFileAlways)(key, value);
161
149
  if (normalized.fails) {
162
150
  return normalized;
163
151
  }
164
- if (update[key]) {
165
- const result = (0, merge_upsert_property_js_1.mergeUpsertProperty)(key, update[key], normalized.value);
152
+ const { ifExists, pattern, transforms } = normalized.value;
153
+ const result = (0, merge_upsert_property_js_1.mergeUpsertProperty)({
154
+ ...normalized.value,
155
+ ifMissing: 'merge',
156
+ }, install);
157
+ if (result.fails) {
158
+ return result;
159
+ }
160
+ if (update) {
161
+ const result = (0, merge_upsert_property_js_1.mergeUpsertProperty)({
162
+ ...normalized.value,
163
+ ifMissing: 'merge',
164
+ }, update);
166
165
  if (result.fails) {
167
166
  return result;
168
167
  }
169
168
  }
170
- else {
171
- update[key] = normalized.value;
172
- }
169
+ uninstall.push({
170
+ ifExists: ifExists === 'force-merge' || ifExists === 'merge' || ifExists === 'overwrite' ? 'skip' : ifExists,
171
+ pattern,
172
+ transforms,
173
+ });
173
174
  }
174
175
  }
175
176
  return (0, xtry_1.ok)({
@@ -1,3 +1,3 @@
1
1
  import { type DResult } from '@zokugun/xtry';
2
- import { type FileUpsert } from '../../types/config.js';
3
- export declare function mergeUpsertProperty(key: string, oldValue: FileUpsert, newValue: FileUpsert): DResult;
2
+ import { type UpsertFileConfig } from '../../types/config.js';
3
+ export declare function mergeUpsertProperty(file: UpsertFileConfig, configs: UpsertFileConfig[]): DResult;
@@ -1,20 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mergeUpsertProperty = mergeUpsertProperty;
4
+ const is_it_type_1 = require("@zokugun/is-it-type");
4
5
  const xtry_1 = require("@zokugun/xtry");
5
6
  const lodash_es_1 = require("lodash-es");
6
- function mergeUpsertProperty(key, oldValue, newValue) {
7
+ function mergeUpsertProperty(file, configs) {
8
+ for (const config of configs) {
9
+ if (config.pattern === file.pattern) {
10
+ return merge(config, file);
11
+ }
12
+ }
13
+ configs.push(file);
14
+ return xtry_1.OK;
15
+ }
16
+ function merge(currentValue, newValue) {
7
17
  if (newValue.filter) {
8
- if (oldValue.filter) {
18
+ if (currentValue.filter) {
9
19
  return (0, xtry_1.err)('Not Implemented: filter');
10
20
  }
11
21
  else {
12
- oldValue.filter = newValue.filter;
22
+ currentValue.filter = newValue.filter;
13
23
  }
14
24
  }
15
25
  if (newValue.ifExists && newValue.ifExists !== 'merge') {
16
- if (oldValue.ifExists) {
17
- if (oldValue.ifExists === 'merge' || oldValue.ifExists === newValue.ifExists) {
26
+ if (currentValue.ifExists) {
27
+ if (currentValue.ifExists === 'merge' || currentValue.ifExists === newValue.ifExists) {
18
28
  // pass
19
29
  }
20
30
  else {
@@ -22,12 +32,12 @@ function mergeUpsertProperty(key, oldValue, newValue) {
22
32
  }
23
33
  }
24
34
  else {
25
- oldValue.ifExists = newValue.ifExists;
35
+ currentValue.ifExists = newValue.ifExists;
26
36
  }
27
37
  }
28
38
  if (newValue.ifMissing && newValue.ifMissing !== 'merge') {
29
- if (oldValue.ifMissing) {
30
- if (oldValue.ifMissing === 'merge' || oldValue.ifMissing === newValue.ifMissing) {
39
+ if (currentValue.ifMissing) {
40
+ if (currentValue.ifMissing === 'merge' || currentValue.ifMissing === newValue.ifMissing) {
31
41
  // pass
32
42
  }
33
43
  else {
@@ -35,33 +45,33 @@ function mergeUpsertProperty(key, oldValue, newValue) {
35
45
  }
36
46
  }
37
47
  else {
38
- oldValue.ifMissing = newValue.ifMissing;
48
+ currentValue.ifMissing = newValue.ifMissing;
39
49
  }
40
50
  }
41
51
  if (newValue.rename) {
42
- if (oldValue.rename) {
52
+ if (currentValue.rename) {
43
53
  return (0, xtry_1.err)('Not Implemented: rename');
44
54
  }
45
55
  else {
46
- oldValue.rename = newValue.rename;
56
+ currentValue.rename = newValue.rename;
47
57
  }
48
58
  }
49
59
  if (newValue.route) {
50
- if (oldValue.route) {
60
+ if (currentValue.route) {
51
61
  return (0, xtry_1.err)('Not Implemented: route');
52
62
  }
53
63
  else {
54
- oldValue.route = newValue.route;
64
+ currentValue.route = newValue.route;
55
65
  }
56
66
  }
57
- if (newValue.transforms && newValue.transforms.length > 0) {
58
- if (oldValue.transforms) {
59
- if (!(0, lodash_es_1.isEqual)(oldValue.transforms, newValue.transforms)) {
60
- return (0, xtry_1.err)(`There is a conflict on the "transforms" property for the "${key}" file`);
67
+ if ((0, is_it_type_1.isNonEmptyArray)(newValue.transforms)) {
68
+ if ((0, is_it_type_1.isNonEmptyArray)(currentValue.transforms)) {
69
+ if (!(0, lodash_es_1.isEqual)(currentValue.transforms, newValue.transforms)) {
70
+ return (0, xtry_1.err)(`There is a conflict on the "transforms" property for the "${newValue.pattern}" file`);
61
71
  }
62
72
  }
63
73
  else {
64
- oldValue.transforms = newValue.transforms;
74
+ currentValue.transforms = newValue.transforms;
65
75
  }
66
76
  }
67
77
  return xtry_1.OK;
@@ -1,3 +1,3 @@
1
1
  import { type DResult } from '@zokugun/xtry';
2
- import { type FileAlways } from '../../types/config.js';
3
- export declare function normalizeFileAlways(data: unknown): DResult<FileAlways>;
2
+ import { type AlwaysFileConfig } from '../../types/config.js';
3
+ export declare function normalizeFileAlways(pattern: string, data: unknown): DResult<AlwaysFileConfig>;
@@ -4,7 +4,7 @@ exports.normalizeFileAlways = normalizeFileAlways;
4
4
  const is_it_type_1 = require("@zokugun/is-it-type");
5
5
  const xtry_1 = require("@zokugun/xtry");
6
6
  const is_transform_js_1 = require("./is-transform.js");
7
- function normalizeFileAlways(data) {
7
+ function normalizeFileAlways(pattern, data) {
8
8
  if (!(0, is_it_type_1.isRecord)(data)) {
9
9
  return (0, xtry_1.err)('"always" must be an object.');
10
10
  }
@@ -23,6 +23,7 @@ function normalizeFileAlways(data) {
23
23
  }
24
24
  return (0, xtry_1.ok)({
25
25
  ifExists,
26
+ pattern,
26
27
  transforms,
27
28
  });
28
29
  } // }}}
@@ -1,3 +1,3 @@
1
1
  import { type DResult } from '@zokugun/xtry';
2
- import { type FileUninstall } from '../../types/config.js';
3
- export declare function normalizeFileUninstall(data: unknown): DResult<FileUninstall>;
2
+ import { type UninstallFileConfig } from '../../types/config.js';
3
+ export declare function normalizeFileUninstall(pattern: string, data: unknown): DResult<UninstallFileConfig>;
@@ -4,7 +4,7 @@ exports.normalizeFileUninstall = normalizeFileUninstall;
4
4
  const is_it_type_1 = require("@zokugun/is-it-type");
5
5
  const xtry_1 = require("@zokugun/xtry");
6
6
  const is_transform_js_1 = require("./is-transform.js");
7
- function normalizeFileUninstall(data) {
7
+ function normalizeFileUninstall(pattern, data) {
8
8
  if (!(0, is_it_type_1.isRecord)(data)) {
9
9
  return (0, xtry_1.err)('"uninstall" must be an object.');
10
10
  }
@@ -26,6 +26,7 @@ function normalizeFileUninstall(data) {
26
26
  }
27
27
  return (0, xtry_1.ok)({
28
28
  ifExists,
29
+ pattern,
29
30
  transforms,
30
31
  });
31
32
  } // }}}
@@ -1,3 +1,3 @@
1
1
  import { type DResult } from '@zokugun/xtry';
2
- import { type FileUpsert } from '../../types/config.js';
3
- export declare function normalizeFileUpsert(data: unknown, name: 'install' | 'update' | 'upsert'): DResult<FileUpsert>;
2
+ import { type UpsertFileConfig } from '../../types/config.js';
3
+ export declare function normalizeFileUpsert(pattern: string, data: unknown, name: 'install' | 'update' | 'upsert'): DResult<UpsertFileConfig>;
@@ -4,7 +4,7 @@ exports.normalizeFileUpsert = normalizeFileUpsert;
4
4
  const is_it_type_1 = require("@zokugun/is-it-type");
5
5
  const xtry_1 = require("@zokugun/xtry");
6
6
  const is_transform_js_1 = require("./is-transform.js");
7
- function normalizeFileUpsert(data, name) {
7
+ function normalizeFileUpsert(pattern, data, name) {
8
8
  if (!(0, is_it_type_1.isRecord)(data)) {
9
9
  return (0, xtry_1.err)(`"${name}" must be an object.`);
10
10
  }
@@ -47,6 +47,7 @@ function normalizeFileUpsert(data, name) {
47
47
  filter,
48
48
  ifExists,
49
49
  ifMissing,
50
+ pattern,
50
51
  rename,
51
52
  route,
52
53
  transforms,
@@ -1,6 +1,6 @@
1
1
  import { type AsyncDResult } from '@zokugun/xtry';
2
+ import { type TextFile } from '../types/context.js';
2
3
  import { type Format } from '../types/format.js';
3
- import { type TextFile } from '../types/text-file.js';
4
4
  export declare function applyFormatting({ formats, mergedTextFiles, transformedFiles }: {
5
5
  formats: Format[];
6
6
  mergedTextFiles: TextFile[];
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.applyFormatting = applyFormatting;
7
4
  const xtry_1 = require("@zokugun/xtry");
8
- const detect_indent_1 = __importDefault(require("detect-indent"));
9
5
  const format_js_1 = require("../types/format.js");
6
+ const detect_indent_js_1 = require("../utils/detect-indent.js");
10
7
  const get_format_js_1 = require("../utils/get-format.js");
11
8
  function applyFormat(file, format) {
12
9
  if (format.indentStyle === format_js_1.IndentStyle.SPACE) {
@@ -23,29 +20,39 @@ function applyFormat(file, format) {
23
20
  }
24
21
  } // }}}
25
22
  function indentWithSpace(data, size) {
26
- const { type, indent } = (0, detect_indent_1.default)(data);
27
- if (type === 'space') {
28
- if (indent.length === size) {
23
+ const indent = (0, detect_indent_js_1.detectIndent)(data);
24
+ if (!indent) {
25
+ return data;
26
+ }
27
+ else if (indent.style === format_js_1.IndentStyle.SPACE) {
28
+ if (indent.size === size) {
29
29
  return data;
30
30
  }
31
31
  else {
32
- data = data.replaceAll(new RegExp(indent, 'gm'), '\t');
32
+ const oldIndent = ' '.repeat(indent.size);
33
33
  const newIndent = ' '.repeat(size);
34
- return data.replaceAll(/\t/gm, newIndent);
34
+ const space2tab = new RegExp(`^(?:${oldIndent})+`, 'gm');
35
+ data = data.replaceAll(space2tab, (spaces) => '\t'.repeat(spaces.length / indent.size));
36
+ return data.replaceAll(/^\t+/gm, (tabs) => newIndent.repeat(tabs.length));
35
37
  }
36
38
  }
37
- else if (type === 'tab') {
39
+ else if (indent.style === format_js_1.IndentStyle.TAB) {
38
40
  const newIndent = ' '.repeat(size);
39
- return data.replaceAll(new RegExp(indent, 'gm'), newIndent);
41
+ return data.replaceAll(/^\t+/gm, (tabs) => newIndent.repeat(tabs.length));
40
42
  }
41
43
  else {
42
44
  return data;
43
45
  }
44
46
  } // }}}
45
47
  function indentWithTab(data) {
46
- const { type, indent, amount } = (0, detect_indent_1.default)(data);
47
- if (type === 'space' && amount > 1) {
48
- return data.replaceAll(new RegExp(indent, 'gm'), '\t');
48
+ const indent = (0, detect_indent_js_1.detectIndent)(data);
49
+ if (!indent) {
50
+ return data;
51
+ }
52
+ else if (indent.style === format_js_1.IndentStyle.SPACE) {
53
+ const oldIndent = ' '.repeat(indent.size);
54
+ const space2tab = new RegExp(`^(?:${oldIndent})+`, 'gm');
55
+ return data.replaceAll(space2tab, (spaces) => '\t'.repeat(spaces.length / indent.size));
49
56
  }
50
57
  else {
51
58
  return data;
@@ -57,6 +64,13 @@ async function applyFormatting({ formats, mergedTextFiles, transformedFiles }) {
57
64
  if (format) {
58
65
  applyFormat(file, format);
59
66
  }
67
+ else if (file.indent) {
68
+ applyFormat(file, {
69
+ indentStyle: file.indent.style,
70
+ indentSize: file.indent.size,
71
+ insertFinalNewline: file.finalNewLine,
72
+ });
73
+ }
60
74
  }
61
75
  if (transformedFiles) {
62
76
  for (const file of transformedFiles) {
@@ -64,6 +78,13 @@ async function applyFormatting({ formats, mergedTextFiles, transformedFiles }) {
64
78
  if (format) {
65
79
  applyFormat(file, format);
66
80
  }
81
+ else if (file.indent) {
82
+ applyFormat(file, {
83
+ indentStyle: file.indent.style,
84
+ indentSize: file.indent.size,
85
+ insertFinalNewline: file.finalNewLine,
86
+ });
87
+ }
67
88
  }
68
89
  }
69
90
  return xtry_1.OK;
@@ -10,31 +10,34 @@ async function configureInstallFileActions(context) {
10
10
  if (!install) {
11
11
  return xtry_1.OK;
12
12
  }
13
- const overwrites = [];
13
+ const existingActions = [];
14
14
  const filters = {};
15
15
  const routes = {};
16
16
  const transformations = {};
17
- for (const [file, fileUpdate] of Object.entries(install)) {
18
- const { filter, ifExists, rename, route, transforms } = fileUpdate;
17
+ for (const file of install) {
18
+ const { filter, ifExists, pattern, rename, route, transforms } = file;
19
19
  if (rename) {
20
20
  context.renamedPatterns.push({
21
- from: file,
21
+ from: pattern,
22
22
  to: rename,
23
23
  });
24
24
  continue;
25
25
  }
26
- if (ifExists === 'overwrite') {
27
- overwrites.push(file);
26
+ if (ifExists === 'force-merge') {
27
+ existingActions.push({ pattern, action: 'merge' });
28
+ }
29
+ else if (ifExists === 'overwrite') {
30
+ existingActions.push({ pattern, action: 'overwrite' });
28
31
  }
29
32
  else if (ifExists === 'remove') {
30
- context.removedPatterns.push(file);
33
+ context.removedPatterns.push(pattern);
31
34
  continue;
32
35
  }
33
36
  else if (ifExists === 'skip') {
34
37
  continue;
35
38
  }
36
39
  if (filter) {
37
- filters[file] = filter;
40
+ filters[pattern] = filter;
38
41
  }
39
42
  if (route) {
40
43
  const { alias } = route;
@@ -43,23 +46,30 @@ async function configureInstallFileActions(context) {
43
46
  return travel;
44
47
  }
45
48
  if (alias) {
46
- routes[file] = {
49
+ routes[pattern] = {
47
50
  alias,
48
51
  travel: travel.value,
49
52
  };
50
53
  }
51
54
  else {
52
- routes[file] = {
55
+ routes[pattern] = {
53
56
  travel: travel.value,
54
57
  };
55
58
  }
56
59
  }
57
60
  if (transforms) {
58
- transformations[file] = transforms;
61
+ transformations[pattern] = transforms;
59
62
  }
60
63
  }
61
- if (overwrites.length > 0) {
62
- context.onExisting = (file) => (0, micromatch_1.isMatch)(file, overwrites) ? 'overwrite' : 'merge';
64
+ if (existingActions.length > 0) {
65
+ context.onExisting = (file) => {
66
+ for (const { pattern, action } of existingActions) {
67
+ if ((0, micromatch_1.isMatch)(file, pattern)) {
68
+ return action;
69
+ }
70
+ }
71
+ return 'merge';
72
+ };
63
73
  }
64
74
  if ((0, is_it_type_1.isNonEmptyRecord)(filters)) {
65
75
  context.filters = (file) => {
@@ -9,6 +9,8 @@ const async_1 = __importDefault(require("@zokugun/fs-extra-plus/async"));
9
9
  const is_it_type_1 = require("@zokugun/is-it-type");
10
10
  const xtry_1 = require("@zokugun/xtry");
11
11
  const micromatch_1 = require("micromatch");
12
+ const detect_indent_js_1 = require("../utils/detect-indent.js");
13
+ const has_final_new_line_js_1 = require("../utils/has-final-new-line.js");
12
14
  async function configureUninstallFileActions(context) {
13
15
  const { uninstall } = context.incomingConfig;
14
16
  if (!uninstall) {
@@ -16,27 +18,29 @@ async function configureUninstallFileActions(context) {
16
18
  }
17
19
  const cwd = node_path_1.default.join(context.incomingPath, 'configs');
18
20
  const transformations = {};
19
- for (const [file, fileUpdate] of Object.entries(uninstall)) {
20
- const { ifExists, transforms } = fileUpdate;
21
+ for (const file of uninstall) {
22
+ const { ifExists, pattern, transforms } = file;
21
23
  if (ifExists === 'remove') {
22
- context.removedPatterns.push(file);
24
+ context.removedPatterns.push(pattern);
23
25
  }
24
26
  else if (ifExists === 'unmerge') {
25
- const filePath = node_path_1.default.join(cwd, file);
27
+ const filePath = node_path_1.default.join(cwd, pattern);
26
28
  const result = await async_1.default.readFile(filePath, 'utf8');
27
29
  if (result.fails) {
28
30
  return (0, xtry_1.err)((0, xtry_1.stringifyError)(result.error));
29
31
  }
30
32
  const data = result.value;
31
- const finalNewLine = data.endsWith('\n');
33
+ const finalNewLine = (0, has_final_new_line_js_1.hasFinalNewLine)(data);
34
+ const indent = (0, detect_indent_js_1.detectIndent)(data);
32
35
  context.textFiles.push({
33
- name: file,
36
+ name: pattern,
34
37
  data,
35
38
  finalNewLine,
39
+ indent,
36
40
  });
37
41
  }
38
42
  if (transforms) {
39
- transformations[file] = transforms;
43
+ transformations[pattern] = transforms;
40
44
  }
41
45
  }
42
46
  if ((0, is_it_type_1.isNonEmptyRecord)(transformations)) {
@@ -12,42 +12,38 @@ async function configureUpdateFileActions(context) {
12
12
  context.onMissing = () => 'skip';
13
13
  }
14
14
  else {
15
- const existingActions = {
16
- merge: [],
17
- overwrite: [],
18
- skip: [],
19
- };
15
+ const existingActions = [];
20
16
  const skipMissings = [];
21
17
  const filters = {};
22
18
  const routes = {};
23
19
  const transformations = {};
24
- for (const [file, fileUpdate] of Object.entries(update)) {
25
- const { filter, ifExists, ifMissing, rename, route, transforms } = fileUpdate;
20
+ for (const file of update) {
21
+ const { filter, ifExists, ifMissing, pattern, rename, route, transforms } = file;
26
22
  if (rename) {
27
23
  context.renamedPatterns.push({
28
- from: file,
24
+ from: pattern,
29
25
  to: rename,
30
26
  });
31
27
  continue;
32
28
  }
33
29
  if (ifMissing === 'skip') {
34
- skipMissings.push(file);
30
+ skipMissings.push(pattern);
35
31
  }
36
32
  if (ifExists === 'force-merge') {
37
- existingActions.merge.push(file);
38
- }
39
- else if (ifExists === 'skip') {
40
- existingActions.skip.push(file);
33
+ existingActions.push({ pattern, action: 'merge' });
41
34
  }
42
35
  else if (ifExists === 'overwrite') {
43
- existingActions.overwrite.push(file);
36
+ existingActions.push({ pattern, action: 'overwrite' });
44
37
  }
45
38
  else if (ifExists === 'remove') {
46
- context.removedPatterns.push(file);
39
+ context.removedPatterns.push(pattern);
47
40
  continue;
48
41
  }
42
+ else if (ifExists === 'skip') {
43
+ existingActions.push({ pattern, action: 'skip' });
44
+ }
49
45
  if (filter) {
50
- filters[file] = filter;
46
+ filters[pattern] = filter;
51
47
  }
52
48
  if (route) {
53
49
  const { alias } = route;
@@ -56,28 +52,28 @@ async function configureUpdateFileActions(context) {
56
52
  return travel;
57
53
  }
58
54
  if (alias) {
59
- routes[file] = {
55
+ routes[pattern] = {
60
56
  alias,
61
57
  travel: travel.value,
62
58
  };
63
59
  }
64
60
  else {
65
- routes[file] = {
61
+ routes[pattern] = {
66
62
  travel: travel.value,
67
63
  };
68
64
  }
69
65
  }
70
66
  if (transforms) {
71
- transformations[file] = transforms;
67
+ transformations[pattern] = transforms;
72
68
  }
73
69
  }
74
70
  if (skipMissings.length > 0) {
75
71
  context.onMissing = (file) => (0, micromatch_1.isMatch)(file, skipMissings) ? 'skip' : 'continue';
76
72
  }
77
- if (existingActions.overwrite.length > 0 || existingActions.skip.length > 0) {
73
+ if (existingActions.length > 0) {
78
74
  context.onExisting = (file) => {
79
- for (const [action, files] of Object.entries(existingActions)) {
80
- if ((0, micromatch_1.isMatch)(file, files)) {
75
+ for (const { pattern, action } of existingActions) {
76
+ if ((0, micromatch_1.isMatch)(file, pattern)) {
81
77
  return action;
82
78
  }
83
79
  }
@@ -1,5 +1,5 @@
1
1
  import { type AsyncDResult } from '@zokugun/xtry';
2
- import { type TextFile } from '../types/text-file.js';
2
+ import { type TextFile } from '../types/context.js';
3
3
  export declare function insertFinalNewLine({ mergedTextFiles, transformedFiles }: {
4
4
  mergedTextFiles: TextFile[];
5
5
  transformedFiles?: TextFile[];
@@ -9,6 +9,8 @@ const cli_utils_1 = require("@zokugun/cli-utils");
9
9
  const async_1 = __importDefault(require("@zokugun/fs-extra-plus/async"));
10
10
  const xtry_1 = require("@zokugun/xtry");
11
11
  const index_js_1 = require("../journeys/index.js");
12
+ const detect_indent_js_1 = require("../utils/detect-indent.js");
13
+ const has_final_new_line_js_1 = require("../utils/has-final-new-line.js");
12
14
  async function mergeTextFiles({ targetPath, textFiles, mergedTextFiles, onExisting, onMissing, filters, routes, transforms, options }) {
13
15
  for (const file of textFiles) {
14
16
  if (options.verbose) {
@@ -61,6 +63,8 @@ async function mergeTextFiles({ targetPath, textFiles, mergedTextFiles, onExisti
61
63
  if (current.fails) {
62
64
  return (0, xtry_1.err)((0, xtry_1.stringifyError)(current.error));
63
65
  }
66
+ const finalNewLine = (0, has_final_new_line_js_1.hasFinalNewLine)(current.value);
67
+ const indent = (0, detect_indent_js_1.detectIndent)(current.value);
64
68
  const data = await journey.travel({
65
69
  current: current.value,
66
70
  incoming: file.data,
@@ -70,7 +74,8 @@ async function mergeTextFiles({ targetPath, textFiles, mergedTextFiles, onExisti
70
74
  mergedTextFiles.push({
71
75
  name: fileName,
72
76
  data,
73
- finalNewLine: file.finalNewLine,
77
+ finalNewLine,
78
+ indent,
74
79
  mode: file.mode,
75
80
  });
76
81
  if (options.verbose) {
@@ -10,6 +10,8 @@ const async_1 = __importDefault(require("@zokugun/fs-extra-plus/async"));
10
10
  const xtry_1 = require("@zokugun/xtry");
11
11
  const globby_1 = __importDefault(require("globby"));
12
12
  const istextorbinary_1 = require("istextorbinary");
13
+ const detect_indent_js_1 = require("../utils/detect-indent.js");
14
+ const has_final_new_line_js_1 = require("../utils/has-final-new-line.js");
13
15
  const read_buffer_js_1 = require("../utils/read-buffer.js");
14
16
  async function readFiles({ incomingPath, textFiles, binaryFiles, options }) {
15
17
  const cwd = path_1.default.join(incomingPath, 'configs');
@@ -26,7 +28,8 @@ async function readFiles({ incomingPath, textFiles, binaryFiles, options }) {
26
28
  return (0, xtry_1.err)((0, xtry_1.stringifyError)(result.error));
27
29
  }
28
30
  const data = result.value;
29
- const finalNewLine = data.endsWith('\n');
31
+ const finalNewLine = (0, has_final_new_line_js_1.hasFinalNewLine)(data);
32
+ const indent = (0, detect_indent_js_1.detectIndent)(data);
30
33
  if (data.startsWith('#!')) {
31
34
  // the text file might be executable
32
35
  const result = await async_1.default.stat(filePath);
@@ -37,8 +40,9 @@ async function readFiles({ incomingPath, textFiles, binaryFiles, options }) {
37
40
  textFiles.push({
38
41
  name: file,
39
42
  data,
40
- mode,
41
43
  finalNewLine,
44
+ indent,
45
+ mode,
42
46
  });
43
47
  if (options.verbose) {
44
48
  cli_utils_1.logger.debug(`${file} is a shebang file`);
@@ -49,6 +53,7 @@ async function readFiles({ incomingPath, textFiles, binaryFiles, options }) {
49
53
  name: file,
50
54
  data,
51
55
  finalNewLine,
56
+ indent,
52
57
  });
53
58
  if (options.verbose) {
54
59
  cli_utils_1.logger.debug(`${file} is a text file`);
@@ -12,7 +12,6 @@ const xtry_1 = require("@zokugun/xtry");
12
12
  const globby_1 = __importDefault(require("globby"));
13
13
  const index_js_1 = require("../journeys/index.js");
14
14
  const detect_indent_js_1 = require("../utils/detect-indent.js");
15
- const get_format_js_1 = require("../utils/get-format.js");
16
15
  const has_final_new_line_js_1 = require("../utils/has-final-new-line.js");
17
16
  async function transformUntouchedFiles({ formats, options, routes, targetPath, textFiles, transformedFiles, transforms }) {
18
17
  if (transforms.length === 0) {
@@ -44,7 +43,8 @@ async function transformUntouchedFiles({ formats, options, routes, targetPath, t
44
43
  return (0, xtry_1.err)((0, xtry_1.stringifyError)(result.error));
45
44
  }
46
45
  const data = result.value;
47
- const finalNewLine = data.endsWith('\n');
46
+ const finalNewLine = (0, has_final_new_line_js_1.hasFinalNewLine)(data);
47
+ const indent = (0, detect_indent_js_1.detectIndent)(data);
48
48
  const transformed = await journey.travel({
49
49
  current: data,
50
50
  incoming: undefined,
@@ -53,21 +53,12 @@ async function transformUntouchedFiles({ formats, options, routes, targetPath, t
53
53
  transformedFiles.push({
54
54
  name: file,
55
55
  data: transformed,
56
- finalNewLine: finalNewLine,
56
+ finalNewLine,
57
+ indent,
57
58
  });
58
59
  if (options.verbose) {
59
60
  cli_utils_1.logger.debug(`${file} has been transformed`);
60
61
  }
61
- const format = (0, get_format_js_1.getFormat)(file, formats);
62
- if (!format) {
63
- const indent = (0, detect_indent_js_1.detectIndent)(data);
64
- formats.push({
65
- glob: file,
66
- indentStyle: indent.style,
67
- indentSize: indent.size,
68
- insertFinalNewline: (0, has_final_new_line_js_1.hasFinalNewLine)(data),
69
- });
70
- }
71
62
  }
72
63
  return xtry_1.OK;
73
64
  }
@@ -47,6 +47,7 @@ async function unmergeTextFiles({ targetPath, textFiles, mergedTextFiles, option
47
47
  name: file.name,
48
48
  data,
49
49
  finalNewLine: file.finalNewLine,
50
+ indent: file.indent,
50
51
  mode: file.mode,
51
52
  });
52
53
  if (options.verbose) {
@@ -1,3 +1,4 @@
1
+ import { type Indent } from './format.js';
1
2
  export type Request = {
2
3
  name: string;
3
4
  variant?: string;
@@ -9,10 +10,10 @@ export type PackageManifest = {
9
10
  export type PackageConfig = {
10
11
  constants: Record<string, string>;
11
12
  extends?: string;
12
- install: Record<string, FileInstall>;
13
+ install: InstallFileConfig[];
13
14
  orphan: boolean;
14
- uninstall: Record<string, FileUninstall>;
15
- update: false | Record<string, FileUpdate>;
15
+ uninstall: UninstallFileConfig[];
16
+ update: false | UpdateFileConfig[];
16
17
  variables: Record<string, string>;
17
18
  variants: Record<string, string>;
18
19
  };
@@ -27,26 +28,25 @@ export type ArtifactResult = Artifact & {
27
28
  export type InstallConfig = {
28
29
  artifacts: Record<string, Artifact>;
29
30
  constants: Record<string, string>;
30
- install: Record<string, FileInstall>;
31
- update: false | Record<string, FileUpdate>;
31
+ install: Record<string, InstallFileConfig>;
32
+ update: false | Record<string, UpdateFileConfig>;
32
33
  variables: Record<string, string>;
33
34
  };
34
- export type FileAlways = {
35
- ifExists: 'force-merge' | 'merge' | 'overwrite' | 'remove' | 'skip';
35
+ export type FileConfig<E> = {
36
+ ifExists: E;
37
+ pattern: string;
36
38
  transforms: FileTransform[];
37
39
  };
38
- export type FileUpsert = FileAlways & {
40
+ export type AlwaysFileConfig = FileConfig<'force-merge' | 'merge' | 'overwrite' | 'remove' | 'skip'>;
41
+ export type InstallFileConfig = UpsertFileConfig;
42
+ export type UninstallFileConfig = FileConfig<'remove' | 'skip' | 'unmerge'>;
43
+ export type UpdateFileConfig = UpsertFileConfig;
44
+ export type UpsertFileConfig = AlwaysFileConfig & {
39
45
  filter?: string[];
40
46
  ifMissing: 'merge' | 'skip';
41
47
  rename?: string;
42
48
  route?: Record<string, any>;
43
49
  };
44
- export type FileInstall = FileUpsert & {};
45
- export type FileUninstall = {
46
- ifExists: 'remove' | 'skip' | 'unmerge';
47
- transforms: FileTransform[];
48
- };
49
- export type FileUpdate = FileUpsert & {};
50
50
  export type FileTransform = {
51
51
  description?: string;
52
52
  jq: string;
@@ -55,4 +55,5 @@ export type InstallConfigStats = {
55
55
  name: string;
56
56
  type: string;
57
57
  finalNewLine: boolean;
58
+ indent?: Indent;
58
59
  };
@@ -1,8 +1,7 @@
1
1
  import { type AsyncDResult } from '@zokugun/xtry';
2
2
  import { type BinaryFile } from './binary-file.js';
3
3
  import { type Request, type InstallConfig, type PackageConfig, type ArtifactResult, type PackageManifest, type FileTransform } from './config.js';
4
- import { type Format } from './format.js';
5
- import { type TextFile } from './text-file.js';
4
+ import { type Indent, type Format } from './format.js';
6
5
  import { type Journey } from './travel.js';
7
6
  export type ExistingAction = 'merge' | 'overwrite' | 'skip';
8
7
  export type MissingAction = 'continue' | 'skip';
@@ -54,3 +53,10 @@ export type Block = {
54
53
  branch?: string;
55
54
  incomingPath: string;
56
55
  };
56
+ export type TextFile = {
57
+ data: string;
58
+ finalNewLine: boolean;
59
+ indent?: Indent;
60
+ mode?: number;
61
+ name: string;
62
+ };
@@ -1,2 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ // export type OutputTextFile = {
4
+ // data: string;
5
+ // name: string;
6
+ // };
@@ -8,3 +8,7 @@ export type Format = {
8
8
  indentSize: number;
9
9
  insertFinalNewline: boolean;
10
10
  };
11
+ export type Indent = {
12
+ style: IndentStyle;
13
+ size: number;
14
+ };
@@ -1,5 +1,2 @@
1
- import { IndentStyle } from '../types/format.js';
2
- export declare function detectIndent(text: string): {
3
- style: IndentStyle;
4
- size: number;
5
- };
1
+ import { type Indent } from '../types/format.js';
2
+ export declare function detectIndent(text: string): Indent | undefined;
@@ -27,6 +27,9 @@ function detectIndent(text) {
27
27
  size: 1,
28
28
  };
29
29
  }
30
+ if (indentations.size === 0) {
31
+ return undefined;
32
+ }
30
33
  const sorted = [...indentations].sort((a, b) => a - b);
31
34
  const diffs = [];
32
35
  for (let i = 1; i < sorted.length; i++) {
package/package.json CHANGED
@@ -1,125 +1,126 @@
1
1
  {
2
- "name": "@zokugun/artifact",
3
- "description": "Boilerplate your project & keep your configurations up to date",
4
- "version": "0.6.0",
5
- "author": {
6
- "name": "Baptiste Augrain",
7
- "email": "daiyam@zokugun.org"
8
- },
9
- "license": "MIT",
10
- "homepage": "https://github.com/zokugun/artifact",
11
- "repository": {
12
- "type": "git",
13
- "url": "https://github.com/zokugun/artifact.git"
14
- },
15
- "bugs": {
16
- "url": "https://github.com/zokugun/artifact/discussions/categories/issue-triage"
17
- },
18
- "engines": {
19
- "node": ">=18.20"
20
- },
21
- "bin": {
22
- "artifact": "bin/artifact",
23
- "atf": "bin/artifact"
24
- },
25
- "scripts": {
26
- "audit:fix": "npm audit fix --min-release-age=0",
27
- "build": "npm run clean && npm run compile:src",
28
- "ci:lint": "zizmor .",
29
- "ci:lint:fix": "zizmor . --fix=all",
30
- "clean": "rimraf .test lib",
31
- "compile:src": "tsc -p src",
32
- "lint": "xo",
33
- "lint:all": "fixpack && npm run ci:lint && npm run lint",
34
- "lint:fix": "xo --fix",
35
- "prepare": "husky; fixpack || true",
36
- "release": "release-it",
37
- "test": "tsc -p test && mocha",
38
- "test:dev": "mocha",
39
- "test:watch": "tsc-watch -p src -p test --onSuccess 'mocha -g=\"\"'",
40
- "update:artifacts": "artifact update",
41
- "update:ci": "PINACT_MIN_AGE=7 pinact run",
42
- "update:deps": "taze",
43
- "watch:build": "tsc-watch -p src --onSuccess 'npm run build'",
44
- "watch:src": "tsc-watch -p src",
45
- "watch:test": "tsc-watch -p test"
46
- },
47
- "dependencies": {
48
- "@zokugun/cli-utils": "0.3.1",
49
- "@zokugun/configdotts-merge": "0.2.1",
50
- "@zokugun/fs-extra-plus": "0.3.7",
51
- "@zokugun/is-it-type": "0.8.1",
52
- "@zokugun/xtry": "0.11.4",
53
- "dayjs": "1.11.20",
54
- "detect-indent": "6.1.0",
55
- "editorconfig": "0.15.3",
56
- "globby": "11.1.0",
57
- "istextorbinary": "6.0.0",
58
- "jq-wasm": "1.1.0-jq-1.8.1",
59
- "jsonc-parser": "3.3.1",
60
- "lodash-es": "4.18.1",
61
- "micromatch": "4.0.8",
62
- "pacote": "21.5.0",
63
- "semver": "7.7.4",
64
- "tempy": "1.0.1",
65
- "untildify": "4.0.0",
66
- "yaml": "2.8.3"
67
- },
68
- "devDependencies": {
69
- "@commitlint/cli": "19.8.1",
70
- "@commitlint/config-conventional": "19.8.1",
71
- "@types/chai": "4.3.20",
72
- "@types/chai-as-promised": "7.1.8",
73
- "@types/lodash-es": "4.17.12",
74
- "@types/micromatch": "4.0.10",
75
- "@types/mocha": "9.1.1",
76
- "@types/node": "20.19.39",
77
- "@types/npm": "7.19.3",
78
- "@types/pacote": "11.1.8",
79
- "@types/semver": "7.7.1",
80
- "@types/universalify": "1.0.3",
81
- "camelcase": "6.3.0",
82
- "chai": "4.5.0",
83
- "chai-as-promised": "7.1.2",
84
- "eslint": "8.11.0",
85
- "eslint-plugin-chai-friendly": "0.7.4",
86
- "fixpack": "4.0.0",
87
- "husky": "9.1.7",
88
- "lint-staged": "16.4.0",
89
- "memfs": "3.6.0",
90
- "mocha": "9.2.2",
91
- "release-it": "20.0.0-1",
92
- "rewiremock": "3.14.6",
93
- "source-map-support": "0.5.21",
94
- "taze": "19.11.0",
95
- "tsc-watch": "7.2.0",
96
- "typescript": "5.9.3",
97
- "universalify": "2.0.1",
98
- "xo": "0.60.0"
99
- },
100
- "overrides": {
101
- "mocha": {
102
- "diff": "5.2.2",
103
- "js-yaml": "4.1.1",
104
- "minimatch": "4.2.6",
105
- "nanoid": "3.3.11",
106
- "serialize-javascript": "7.0.5"
107
- }
108
- },
109
- "keywords": [
110
- "artifact",
111
- "boilerplate",
112
- "boilerplates",
113
- "codegeneration",
114
- "codemod",
115
- "codemods",
116
- "configuration",
117
- "configurations",
118
- "generate",
119
- "generator",
120
- "project-generator",
121
- "project-starter",
122
- "project-template",
123
- "scaffold"
124
- ]
2
+ "name": "@zokugun/artifact",
3
+ "description": "Boilerplate your project & keep your configurations up to date",
4
+ "version": "0.6.1",
5
+ "author": {
6
+ "name": "Baptiste Augrain",
7
+ "email": "daiyam@zokugun.org"
8
+ },
9
+ "license": "MIT",
10
+ "homepage": "https://github.com/zokugun/artifact",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/zokugun/artifact.git"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/zokugun/artifact/discussions/categories/issue-triage"
17
+ },
18
+ "engines": {
19
+ "node": ">=18.20"
20
+ },
21
+ "bin": {
22
+ "artifact": "bin/artifact",
23
+ "atf": "bin/artifact"
24
+ },
25
+ "scripts": {
26
+ "audit:fix": "npm audit fix --min-release-age=0",
27
+ "build": "npm run clean && npm run compile:src",
28
+ "ci:lint": "zizmor .",
29
+ "ci:lint:fix": "zizmor . --fix=all",
30
+ "clean": "rimraf .test lib",
31
+ "compile:src": "tsc -p src",
32
+ "lint": "xo",
33
+ "lint:all": "fixpack && npm run ci:lint && npm run lint",
34
+ "lint:fix": "xo --fix",
35
+ "prepack": "npm run build",
36
+ "prepare": "husky; fixpack || true",
37
+ "release": "release-it",
38
+ "test": "tsc -p test && mocha",
39
+ "test:dev": "mocha",
40
+ "test:watch": "tsc-watch -p src -p test --onSuccess 'mocha -g=\"\"'",
41
+ "update:artifacts": "artifact update",
42
+ "update:ci": "PINACT_MIN_AGE=7 pinact run",
43
+ "update:deps": "taze",
44
+ "watch:build": "tsc-watch -p src --onSuccess 'npm run build'",
45
+ "watch:src": "tsc-watch -p src",
46
+ "watch:test": "tsc-watch -p test"
47
+ },
48
+ "dependencies": {
49
+ "@zokugun/cli-utils": "0.3.1",
50
+ "@zokugun/configdotts-merge": "0.2.1",
51
+ "@zokugun/fs-extra-plus": "0.3.7",
52
+ "@zokugun/is-it-type": "0.8.1",
53
+ "@zokugun/xtry": "0.11.4",
54
+ "dayjs": "1.11.20",
55
+ "editorconfig": "0.15.3",
56
+ "globby": "11.1.0",
57
+ "istextorbinary": "6.0.0",
58
+ "jq-wasm": "1.1.0-jq-1.8.1",
59
+ "jsonc-parser": "3.3.1",
60
+ "lodash-es": "4.18.1",
61
+ "micromatch": "4.0.8",
62
+ "pacote": "21.5.0",
63
+ "semver": "7.7.4",
64
+ "tempy": "1.0.1",
65
+ "untildify": "4.0.0",
66
+ "yaml": "2.8.3"
67
+ },
68
+ "devDependencies": {
69
+ "@commitlint/cli": "19.8.1",
70
+ "@commitlint/config-conventional": "19.8.1",
71
+ "@types/chai": "4.3.20",
72
+ "@types/chai-as-promised": "7.1.8",
73
+ "@types/lodash-es": "4.17.12",
74
+ "@types/micromatch": "4.0.10",
75
+ "@types/mocha": "9.1.1",
76
+ "@types/node": "20.19.39",
77
+ "@types/npm": "7.19.3",
78
+ "@types/pacote": "11.1.8",
79
+ "@types/semver": "7.7.1",
80
+ "@types/universalify": "1.0.3",
81
+ "camelcase": "6.3.0",
82
+ "chai": "4.5.0",
83
+ "chai-as-promised": "7.1.2",
84
+ "eslint": "8.11.0",
85
+ "eslint-plugin-chai-friendly": "0.7.4",
86
+ "fixpack": "4.0.0",
87
+ "husky": "9.1.7",
88
+ "lint-staged": "16.4.0",
89
+ "memfs": "3.6.0",
90
+ "mocha": "9.2.2",
91
+ "release-it": "20.0.0",
92
+ "rewiremock": "3.14.6",
93
+ "source-map-support": "0.5.21",
94
+ "taze": "19.11.0",
95
+ "tsc-watch": "7.2.0",
96
+ "typescript": "5.9.3",
97
+ "universalify": "2.0.1",
98
+ "xo": "0.60.0"
99
+ },
100
+ "overrides": {
101
+ "mocha": {
102
+ "diff": "5.2.2",
103
+ "glob": "8.1.0",
104
+ "js-yaml": "4.1.1",
105
+ "minimatch": "4.2.6",
106
+ "nanoid": "3.3.11",
107
+ "serialize-javascript": "7.0.5"
108
+ }
109
+ },
110
+ "keywords": [
111
+ "artifact",
112
+ "boilerplate",
113
+ "boilerplates",
114
+ "codegeneration",
115
+ "codemod",
116
+ "codemods",
117
+ "configuration",
118
+ "configurations",
119
+ "generate",
120
+ "generator",
121
+ "project-generator",
122
+ "project-starter",
123
+ "project-template",
124
+ "scaffold"
125
+ ]
125
126
  }
@@ -1,7 +0,0 @@
1
- export type TextFile = {
2
- data: string;
3
- finalNewLine: boolean;
4
- indent?: string;
5
- mode?: number;
6
- name: string;
7
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });