@yeoman/conflicter 0.1.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 The Yeoman Team <admin@simonboudrias.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # @yeoman/namespace
2
+
3
+ [![NPM version][npm-image]][npm-url]
4
+ [![NPM Test](https://github.com/yeoman/yeoman-api/workflows/NPM%20Test/badge.svg)](https://github.com/yeoman/yeoman-api/actions?query=workflow%3A%22NPM+Test%22)
5
+ [![Integration Build](https://github.com/yeoman/yeoman-api/workflows/Integration%20Build/badge.svg)](https://github.com/yeoman/yeoman-api/actions?query=workflow%3A%22Integration+Build%22)
6
+ [![Dependency Status][daviddm-image]][daviddm-url]
7
+
8
+ > Common API for yeoman's generator/environment stack
9
+
10
+ Intended for internal yeoman generator/environment stack use.
11
+
12
+ ## License
13
+
14
+ MIT © [The Yeoman Team](http://yeoman.io)
15
+
16
+ [npm-image]: https://badge.fury.io/js/yeoman-api.svg
17
+ [npm-url]: https://npmjs.org/package/yeoman-api
18
+ [travis-image]: https://travis-ci.org/yeoman/yeoman-api.svg?branch=master
19
+ [travis-url]: https://travis-ci.org/yeoman/yeoman-api
20
+ [daviddm-image]: https://david-dm.org/yeoman/yeoman-api.svg?theme=shields.io
21
+ [daviddm-url]: https://david-dm.org/yeoman/yeoman-api
@@ -0,0 +1,4 @@
1
+ import { Buffer } from 'node:buffer';
2
+ declare const isBinary: (filePath: string, newFileContents?: Buffer | string) => boolean;
3
+ declare const binaryDiff: (existingFilePath: string, newFileContents?: Buffer) => string;
4
+ export { isBinary, binaryDiff };
@@ -0,0 +1,38 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { Buffer } from 'node:buffer';
4
+ import Table from 'cli-table';
5
+ import dateFormat from 'dateformat';
6
+ import prettyBytes from 'pretty-bytes';
7
+ import { isBinaryFileSync } from 'isbinaryfile';
8
+ import textextensions from 'textextensions';
9
+ import binaryExtensions from 'binary-extensions';
10
+ const isBinary = (filePath, newFileContents) => {
11
+ const extension = path.extname(filePath).replace(/^\./, '') || path.basename(filePath);
12
+ if (binaryExtensions.includes(extension)) {
13
+ return true;
14
+ }
15
+ if (textextensions.includes(extension)) {
16
+ return false;
17
+ }
18
+ return Boolean((fs.existsSync(filePath) && isBinaryFileSync(filePath)) ||
19
+ (newFileContents && isBinaryFileSync(Buffer.isBuffer(newFileContents) ? newFileContents : Buffer.from(newFileContents))));
20
+ };
21
+ const binaryDiff = (existingFilePath, newFileContents) => {
22
+ const existingStat = fs.statSync(existingFilePath);
23
+ const table = new Table({
24
+ head: ['', 'Existing', 'Replacement', 'Diff'],
25
+ });
26
+ let sizeDiff;
27
+ if (!newFileContents) {
28
+ newFileContents = Buffer.from([]);
29
+ }
30
+ sizeDiff = existingStat.size > newFileContents.length ? '-' : '+';
31
+ sizeDiff += prettyBytes(Math.abs(existingStat.size - newFileContents.length));
32
+ table.push(['Size', prettyBytes(existingStat.size), prettyBytes(newFileContents.length), sizeDiff],
33
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
34
+ ['Last modified', dateFormat(existingStat.mtime), '', '']);
35
+ return table.toString();
36
+ };
37
+ export { isBinary, binaryDiff };
38
+ //# sourceMappingURL=binary-diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary-diff.js","sourceRoot":"","sources":["../src/binary-diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,MAAM,WAAW,CAAC;AAC9B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,cAAc,MAAM,gBAAgB,CAAC;AAC5C,OAAO,gBAAgB,MAAM,mBAAmB,CAAC;AAEjD,MAAM,QAAQ,GAAG,CAAC,QAAgB,EAAE,eAAiC,EAAW,EAAE;IAChF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACvF,IAAI,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACxC,OAAO,IAAI,CAAC;KACb;IAED,IAAI,cAAc,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACtC,OAAO,KAAK,CAAC;KACd;IAED,OAAO,OAAO,CACZ,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,QAAQ,C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{ InputOutputAdapter } from '@yeoman/types';
2
+ import { type Change } from 'diff';
3
+ import type { Store } from 'mem-fs';
4
+ import { type MemFsEditor, type MemFsEditorFile } from 'mem-fs-editor';
5
+ export type ConflicterStatus = 'create' | 'skip' | 'identical' | 'force';
6
+ export type ConflicterLog = ConflicterStatus | 'conflict';
7
+ export type ConflicterAction = 'write' | 'abort' | 'diff' | 'reload' | 'force' | 'edit';
8
+ export type ConflicterStreamStatus = {
9
+ force: boolean;
10
+ };
11
+ export type ConflicterFile = MemFsEditorFile & {
12
+ conflicterLog?: ConflicterLog;
13
+ conflicter?: ConflicterStatus;
14
+ binary?: boolean;
15
+ conflicterChanges?: Change[];
16
+ };
17
+ export type ConflictedFile = ConflicterFile & {
18
+ conflicterChanges: Change[];
19
+ };
20
+ export type ConflicterOptions = {
21
+ memFs?: Store;
22
+ force?: boolean;
23
+ bail?: boolean;
24
+ ignoreWhitespace?: boolean;
25
+ regenerate?: boolean;
26
+ dryRun?: boolean;
27
+ cwd?: string;
28
+ diffOptions?: any;
29
+ };
30
+ /**
31
+ * The Conflicter is a module that can be used to detect conflict between files. Each
32
+ * Generator file system helpers pass files through this module to make sure they don't
33
+ * break a user file.
34
+ *
35
+ * When a potential conflict is detected, we prompt the user and ask them for
36
+ * confirmation before proceeding with the actual write.
37
+ *
38
+ * @constructor
39
+ * @property {Boolean} force - same as the constructor argument
40
+ *
41
+ * @param {TerminalAdapter} adapter - The generator adapter
42
+ * @param {Object} options - Conflicter options
43
+ * @param {Boolean} [options.force=false] - When set to true, we won't check for conflict. (the conflicter become a passthrough)
44
+ * @param {Boolean} [options.bail=false] - When set to true, we will abort on first conflict. (used for testing reproducibility)
45
+ * @param {Boolean} [options.ignoreWhitespace=false] - When set to true, whitespace changes should not generate a conflict.
46
+ * @param {Boolean} [options.regenerate=false] - When set to true, identical files should be written to disc.
47
+ * @param {Boolean} [options.dryRun=false] - When set to true, no write operation will be executed.
48
+ * @param {Boolean} [options.cwd=process.cwd()] - Path to be used as reference for relative path.
49
+ * @param {string} cwd - Set cwd for relative logs.
50
+ */
51
+ export declare class Conflicter {
52
+ private readonly adapter;
53
+ force: boolean;
54
+ bail: boolean;
55
+ ignoreWhitespace: boolean;
56
+ regenerate: boolean;
57
+ dryRun: boolean;
58
+ cwd: string;
59
+ diffOptions?: any;
60
+ fs?: MemFsEditor<ConflicterFile>;
61
+ constructor(adapter: InputOutputAdapter, options?: ConflicterOptions);
62
+ log(file: ConflicterFile): void;
63
+ _log(logStatus: ConflicterLog | 'writeln' | undefined, ...args: any[]): void;
64
+ /**
65
+ * Print the file differences to console
66
+ *
67
+ * @param {Object} file File object respecting this interface: { path, contents }
68
+ */
69
+ _printDiff({ file, adapter }: {
70
+ file: ConflictedFile;
71
+ adapter?: InputOutputAdapter;
72
+ }): Promise<void>;
73
+ /**
74
+ * Detect conflicts between file contents at `filepath` with the `contents` passed to the
75
+ * function
76
+ *
77
+ * If `filepath` points to a folder, we'll always return true.
78
+ *
79
+ * Based on detect-conflict module
80
+ *
81
+ * @param {import('vinyl')} file File object respecting this interface: { path, contents }
82
+ * @return {Boolean} `true` if there's a conflict, `false` otherwise.
83
+ */
84
+ _detectConflict(file: ConflicterFile): Promise<boolean>;
85
+ /**
86
+ * Check if a file conflict with the current version on the user disk
87
+ *
88
+ * A basic check is done to see if the file exists, if it does:
89
+ *
90
+ * 1. Read its content from `fs`
91
+ * 2. Compare it with the provided content
92
+ * 3. If identical, mark it as is and skip the check
93
+ * 4. If diverged, prepare and show up the file collision menu
94
+ *
95
+ * @param {import('vinyl')} file - Vinyl file
96
+ * @param {Object} [conflicterStatus] - Conflicter status
97
+ * @return {Promise<Vinyl>} Promise the Vinyl file
98
+ */
99
+ checkForCollision(file: ConflicterFile, conflicterStatus?: ConflicterStreamStatus): Promise<ConflicterFile>;
100
+ /**
101
+ * Actual prompting logic
102
+ * @private
103
+ * @param {import('vinyl')} file vinyl file object
104
+ * @param {Number} counter prompts
105
+ */
106
+ _ask({ file, counter, conflicterStatus, adapter, }: {
107
+ file: ConflictedFile;
108
+ counter: number;
109
+ conflicterStatus: ConflicterStreamStatus;
110
+ adapter: InputOutputAdapter;
111
+ }): Promise<ConflicterStatus>;
112
+ }
@@ -0,0 +1,371 @@
1
+ import fs from 'node:fs';
2
+ import { stat as fsStat, readFile } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import process from 'node:process';
5
+ import { Buffer } from 'node:buffer';
6
+ import { diffWords, diffLines } from 'diff';
7
+ import { create as createMemFsEditor } from 'mem-fs-editor';
8
+ import { binaryDiff, isBinary } from './binary-diff.js';
9
+ /**
10
+ * The Conflicter is a module that can be used to detect conflict between files. Each
11
+ * Generator file system helpers pass files through this module to make sure they don't
12
+ * break a user file.
13
+ *
14
+ * When a potential conflict is detected, we prompt the user and ask them for
15
+ * confirmation before proceeding with the actual write.
16
+ *
17
+ * @constructor
18
+ * @property {Boolean} force - same as the constructor argument
19
+ *
20
+ * @param {TerminalAdapter} adapter - The generator adapter
21
+ * @param {Object} options - Conflicter options
22
+ * @param {Boolean} [options.force=false] - When set to true, we won't check for conflict. (the conflicter become a passthrough)
23
+ * @param {Boolean} [options.bail=false] - When set to true, we will abort on first conflict. (used for testing reproducibility)
24
+ * @param {Boolean} [options.ignoreWhitespace=false] - When set to true, whitespace changes should not generate a conflict.
25
+ * @param {Boolean} [options.regenerate=false] - When set to true, identical files should be written to disc.
26
+ * @param {Boolean} [options.dryRun=false] - When set to true, no write operation will be executed.
27
+ * @param {Boolean} [options.cwd=process.cwd()] - Path to be used as reference for relative path.
28
+ * @param {string} cwd - Set cwd for relative logs.
29
+ */
30
+ export class Conflicter {
31
+ adapter;
32
+ force;
33
+ bail;
34
+ ignoreWhitespace;
35
+ regenerate;
36
+ dryRun;
37
+ cwd;
38
+ diffOptions;
39
+ fs;
40
+ constructor(adapter, options) {
41
+ this.adapter = adapter;
42
+ this.fs = createMemFsEditor(options?.memFs);
43
+ this.force = options?.force ?? false;
44
+ this.bail = options?.bail ?? false;
45
+ this.ignoreWhitespace = options?.ignoreWhitespace ?? false;
46
+ this.regenerate = options?.regenerate ?? false;
47
+ this.dryRun = options?.dryRun ?? false;
48
+ this.cwd = path.resolve(options?.cwd ?? process.cwd());
49
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
50
+ this.diffOptions = options?.diffOptions;
51
+ if (this.bail) {
52
+ // Bail conflicts with force option, if bail set force to false.
53
+ this.force = false;
54
+ }
55
+ }
56
+ log(file) {
57
+ const logStatus = file.conflicterLog ?? file.conflicter;
58
+ this._log(logStatus, path.relative(this.cwd, file.path));
59
+ }
60
+ _log(logStatus, ...args) {
61
+ if (logStatus && this.adapter.log[logStatus]) {
62
+ this.adapter.log[logStatus](...args);
63
+ }
64
+ }
65
+ /**
66
+ * Print the file differences to console
67
+ *
68
+ * @param {Object} file File object respecting this interface: { path, contents }
69
+ */
70
+ async _printDiff({ file, adapter }) {
71
+ const destAdapter = adapter ?? this.adapter;
72
+ if (file.binary === undefined) {
73
+ file.binary = isBinary(file.path, file.contents ?? undefined);
74
+ }
75
+ if (file.binary) {
76
+ destAdapter.log.writeln(binaryDiff(file.path, file.contents ?? undefined));
77
+ return;
78
+ }
79
+ const colorLines = (colored) => {
80
+ if (colored.color) {
81
+ const lines = colored.message.split('\n');
82
+ const returnValue = [];
83
+ for (const [idx, message] of lines.entries()) {
84
+ // Empty message can be ignored
85
+ if (message) {
86
+ returnValue.push({ message, color: colored.color });
87
+ }
88
+ if (lines.length > idx) {
89
+ returnValue.push({ message: '\n' });
90
+ }
91
+ }
92
+ return returnValue;
93
+ }
94
+ return [colored];
95
+ };
96
+ const messages = file.conflicterChanges
97
+ ?.map((change) => {
98
+ if (change.added) {
99
+ return { color: 'added', message: change.value };
100
+ }
101
+ if (change.removed) {
102
+ return { color: 'removed', message: change.value };
103
+ }
104
+ return { message: change.value };
105
+ })
106
+ .map((colored) => colorLines(colored));
107
+ destAdapter.log.colored([
108
+ { message: '\n' },
109
+ { message: 'removed', color: 'removed' },
110
+ { message: '' },
111
+ { message: 'added', color: 'added' },
112
+ { message: '\n\n' },
113
+ ...messages.flat(),
114
+ { message: '\n\n' },
115
+ ]);
116
+ }
117
+ /**
118
+ * Detect conflicts between file contents at `filepath` with the `contents` passed to the
119
+ * function
120
+ *
121
+ * If `filepath` points to a folder, we'll always return true.
122
+ *
123
+ * Based on detect-conflict module
124
+ *
125
+ * @param {import('vinyl')} file File object respecting this interface: { path, contents }
126
+ * @return {Boolean} `true` if there's a conflict, `false` otherwise.
127
+ */
128
+ async _detectConflict(file) {
129
+ let { contents, stat } = file;
130
+ const filepath = path.resolve(file.path);
131
+ // If file path point to a directory, then it's not safe to write
132
+ const diskStat = await fsStat(filepath);
133
+ if (diskStat.isDirectory()) {
134
+ return true;
135
+ }
136
+ if (stat?.mode && diskStat.mode !== stat.mode) {
137
+ return true;
138
+ }
139
+ if (file.binary === undefined) {
140
+ file.binary = isBinary(file.path, file.contents ?? undefined);
141
+ }
142
+ const actual = await readFile(path.resolve(filepath));
143
+ if (!Buffer.isBuffer(contents)) {
144
+ contents = Buffer.from(contents ?? '', 'utf8');
145
+ }
146
+ if (file.binary) {
147
+ return actual.toString('hex') !== contents.toString('hex');
148
+ }
149
+ let modified;
150
+ let changes;
151
+ if (this.ignoreWhitespace) {
152
+ changes = diffWords(actual.toString(), contents.toString(), this.diffOptions);
153
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
154
+ modified = changes.some(change => change.value?.trim() && (change.added || change.removed));
155
+ }
156
+ else {
157
+ changes = diffLines(actual.toString(), contents.toString(), this.diffOptions);
158
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
159
+ modified = (changes.length > 1 || changes[0].added || changes[0].removed) ?? false;
160
+ }
161
+ file.conflicterChanges = changes;
162
+ return modified;
163
+ }
164
+ /**
165
+ * Check if a file conflict with the current version on the user disk
166
+ *
167
+ * A basic check is done to see if the file exists, if it does:
168
+ *
169
+ * 1. Read its content from `fs`
170
+ * 2. Compare it with the provided content
171
+ * 3. If identical, mark it as is and skip the check
172
+ * 4. If diverged, prepare and show up the file collision menu
173
+ *
174
+ * @param {import('vinyl')} file - Vinyl file
175
+ * @param {Object} [conflicterStatus] - Conflicter status
176
+ * @return {Promise<Vinyl>} Promise the Vinyl file
177
+ */
178
+ // eslint-disable-next-line unicorn/no-object-as-default-parameter
179
+ async checkForCollision(file, conflicterStatus = { force: false }) {
180
+ const rfilepath = path.relative(this.cwd, file.path);
181
+ if (file.conflicter) {
182
+ this._log(file.conflicter, rfilepath);
183
+ return file;
184
+ }
185
+ if (!fs.existsSync(file.path)) {
186
+ if (this.bail) {
187
+ this._log('writeln', 'Aborting ...');
188
+ throw new Error(`Process aborted by conflict: ${rfilepath}`);
189
+ }
190
+ this._log('create', rfilepath);
191
+ file.conflicter = this.dryRun ? 'skip' : 'create';
192
+ file.conflicterLog = 'create';
193
+ return file;
194
+ }
195
+ const isForce = () => this.force || conflicterStatus?.force;
196
+ if (isForce()) {
197
+ this._log('force', rfilepath);
198
+ file.conflicter = 'force';
199
+ return file;
200
+ }
201
+ if (await this._detectConflict(file)) {
202
+ const conflictedFile = file;
203
+ if (this.bail) {
204
+ this.adapter.log.conflict(rfilepath);
205
+ await this._printDiff({ file: conflictedFile });
206
+ this.adapter.log.writeln('Aborting ...');
207
+ const error = new Error(`Process aborted by conflict: ${rfilepath}`);
208
+ error.file = file;
209
+ throw error;
210
+ }
211
+ if (this.dryRun) {
212
+ this._log('conflict', rfilepath);
213
+ await this._printDiff({ file: conflictedFile });
214
+ file.conflicter = 'skip';
215
+ file.conflicterLog = 'conflict';
216
+ return file;
217
+ }
218
+ if (isForce()) {
219
+ file.conflicter = 'force';
220
+ this.adapter.log.force(rfilepath);
221
+ return file;
222
+ }
223
+ const ask = async (adapter) => {
224
+ adapter.log.conflict(rfilepath);
225
+ const action = await this._ask({ file: conflictedFile, counter: 1, conflicterStatus, adapter });
226
+ adapter.log[action ?? 'force'](rfilepath);
227
+ file.conflicter = action;
228
+ return file;
229
+ };
230
+ if (this.adapter.queue) {
231
+ const file = await this.adapter.queue(ask);
232
+ if (!file) {
233
+ throw new Error('A conflicter file was not returned');
234
+ }
235
+ return file;
236
+ }
237
+ return ask(this.adapter);
238
+ }
239
+ this._log('identical', rfilepath);
240
+ if (!this.regenerate) {
241
+ file.conflicter = 'skip';
242
+ file.conflicterLog = 'identical';
243
+ return file;
244
+ }
245
+ file.conflicter = 'identical';
246
+ return file;
247
+ }
248
+ /**
249
+ * Actual prompting logic
250
+ * @private
251
+ * @param {import('vinyl')} file vinyl file object
252
+ * @param {Number} counter prompts
253
+ */
254
+ async _ask({ file, counter, conflicterStatus, adapter, }) {
255
+ if (file.conflicter) {
256
+ return file.conflicter;
257
+ }
258
+ const rfilepath = path.relative(this.cwd, file.path);
259
+ const prompt = {
260
+ name: 'action',
261
+ type: 'expand',
262
+ message: `Overwrite ${rfilepath}?`,
263
+ pageSize: 20,
264
+ choices: [
265
+ {
266
+ key: 'y',
267
+ name: 'overwrite',
268
+ value: 'write',
269
+ },
270
+ {
271
+ key: 'n',
272
+ name: 'do not overwrite',
273
+ value: 'skip',
274
+ },
275
+ {
276
+ key: 'a',
277
+ name: 'overwrite this and all others',
278
+ value: 'force',
279
+ },
280
+ {
281
+ key: 'r',
282
+ name: 'reload file (experimental)',
283
+ value: 'reload',
284
+ },
285
+ {
286
+ key: 'x',
287
+ name: 'abort',
288
+ value: 'abort',
289
+ },
290
+ ],
291
+ };
292
+ // Only offer diff option for files
293
+ const fileStat = await fsStat(file.path);
294
+ if (fileStat.isFile()) {
295
+ prompt.choices.push({
296
+ key: 'd',
297
+ name: 'show the differences between the old and the new',
298
+ value: 'diff',
299
+ }, {
300
+ key: 'e',
301
+ name: 'edit file (experimental)',
302
+ value: 'edit',
303
+ });
304
+ if (this.fs) {
305
+ prompt.choices.push({
306
+ key: 'i',
307
+ name: 'ignore, do not overwrite and remember (experimental)',
308
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
309
+ // @ts-expect-error
310
+ value: ({ relativeFilePath }) => {
311
+ this.fs.append(`${this.cwd}/.yo-resolve`, `${relativeFilePath} skip`, { create: true });
312
+ return 'skip';
313
+ },
314
+ });
315
+ }
316
+ }
317
+ const result = await adapter.prompt([
318
+ prompt,
319
+ ]);
320
+ if (typeof result.action === 'function') {
321
+ return result.action.call(this, { file, relativeFilePath: rfilepath, adapter });
322
+ }
323
+ if (result.action === 'abort') {
324
+ adapter.log.writeln('Aborting ...');
325
+ throw new Error('Process aborted by user');
326
+ }
327
+ if (result.action === 'diff') {
328
+ await this._printDiff({ file, adapter });
329
+ counter++;
330
+ if (counter === 5) {
331
+ throw new Error(`Recursive error ${prompt.message}`);
332
+ }
333
+ return this._ask({ file, counter, conflicterStatus, adapter });
334
+ }
335
+ if (result.action === 'force') {
336
+ if (conflicterStatus) {
337
+ conflicterStatus.force = true;
338
+ }
339
+ else {
340
+ this.force = true;
341
+ }
342
+ }
343
+ if (result.action === 'write') {
344
+ return 'force';
345
+ }
346
+ if (result.action === 'reload') {
347
+ if (await this._detectConflict(file)) {
348
+ return this._ask({ file, counter, conflicterStatus, adapter });
349
+ }
350
+ return 'identical';
351
+ }
352
+ if (result.action === 'edit') {
353
+ const answers = await adapter.prompt([
354
+ {
355
+ name: 'content',
356
+ type: 'editor',
357
+ default: file.contents?.toString(),
358
+ postfix: `.${path.extname(file.path)}`,
359
+ message: `Edit ${rfilepath}`,
360
+ },
361
+ ]);
362
+ file.contents = Buffer.from(answers.content ?? '', 'utf8');
363
+ if (await this._detectConflict(file)) {
364
+ return this._ask({ file, counter, conflicterStatus, adapter });
365
+ }
366
+ return 'skip';
367
+ }
368
+ return result.action;
369
+ }
370
+ }
371
+ //# sourceMappingURL=conflicter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conflicter.js","sourceRoot":"","sources":["../src/conflicter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,QAAQ,E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IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,CAAC;aAChE;YAED,OAAO,MAAM,CAAC;SACf;QAED,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@yeoman/conflicter",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "description": "Conflict resolution for yeoman's generator/environment stack",
6
+ "keywords": [
7
+ "yeoman",
8
+ "api"
9
+ ],
10
+ "homepage": "http://yeoman.io",
11
+ "repository": "yeoman/yeoman-api",
12
+ "license": "MIT",
13
+ "author": "The Yeoman Team",
14
+ "type": "module",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
+ }
20
+ },
21
+ "main": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "scripts": {
27
+ "prebuild": "npm run clean",
28
+ "build": "tsc",
29
+ "clean": "rimraf dist",
30
+ "clean-all": "npm run clean && rimraf node_modules",
31
+ "precommit": "lint-staged",
32
+ "pretest": "xo",
33
+ "test": "c8 esmocha --forbid-only"
34
+ },
35
+ "dependencies": {
36
+ "@yeoman/types": "^0.2.0",
37
+ "binary-extensions": "^2.2.0",
38
+ "cli-table": "^0.3.11",
39
+ "dateformat": "^5.0.3",
40
+ "diff": "^5.1.0",
41
+ "isbinaryfile": "^5.0.0",
42
+ "mem-fs": "^3.0.0",
43
+ "mem-fs-editor": "^10.0.2",
44
+ "pretty-bytes": "^6.1.0",
45
+ "textextensions": "^5.16.0"
46
+ },
47
+ "devDependencies": {
48
+ "@types/cli-table": "^0.3.1",
49
+ "@types/dateformat": "^5.0.0",
50
+ "@types/diff": "^5.0.3",
51
+ "@types/textextensions": "^2.4.0",
52
+ "@yeoman/adapter": "^0.1.0",
53
+ "esmocha": "^0.1.4",
54
+ "lodash-es": "^4.17.21",
55
+ "sinon": "^15.0.4",
56
+ "slash": "^5.1.0",
57
+ "yeoman-test": "^8.0.0-beta.0"
58
+ },
59
+ "engines": {
60
+ "node": "^16.13.0 || >=18.12.0"
61
+ },
62
+ "publishConfig": {
63
+ "access": "public",
64
+ "registry": "https://registry.npmjs.org/"
65
+ },
66
+ "gitHead": "1982816cfe6af4e92f999e344cf9b8539ff308eb"
67
+ }