mirror of
https://github.com/HeyPuter/puter.git
synced 2025-01-23 06:00:21 +08:00
dev(tools): add conflict prompt to license-headers
This commit is contained in:
parent
f006c9ed26
commit
d0a5a57c88
15
package-lock.json
generated
15
package-lock.json
generated
@ -5033,7 +5033,6 @@
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz",
|
||||
"integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
@ -6932,6 +6931,19 @@
|
||||
"node": ">=10.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/enquirer": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.4.1.tgz",
|
||||
"integrity": "sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-colors": "^4.1.1",
|
||||
"strip-ansi": "^6.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.6"
|
||||
}
|
||||
},
|
||||
"node_modules/entities": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
|
||||
@ -14654,6 +14666,7 @@
|
||||
"console-table-printer": "^2.12.1",
|
||||
"dedent": "^1.5.3",
|
||||
"diff-match-patch": "^1.0.5",
|
||||
"enquirer": "^2.4.1",
|
||||
"js-levenshtein": "^1.1.6",
|
||||
"yaml": "^2.4.5"
|
||||
}
|
||||
|
@ -128,8 +128,7 @@ const BlockCommentParser = ({
|
||||
return {
|
||||
parse: async (stream) => {
|
||||
stream.skip_whitespace();
|
||||
stream.debug('starting at', await stream.debug())
|
||||
if ( ! stream.matches(start) ) return;
|
||||
if ( ! await stream.matches(start) ) return;
|
||||
stream.fwd(start.length);
|
||||
const contents = await stream.get_until(end);
|
||||
if ( ! contents ) return;
|
||||
@ -221,7 +220,7 @@ const CommentParser = () => {
|
||||
javascript: {
|
||||
parsers: [
|
||||
['lines', {
|
||||
prefix: '// ',
|
||||
prefix: '//',
|
||||
}],
|
||||
['block', {
|
||||
start: '/*',
|
||||
@ -231,7 +230,7 @@ const CommentParser = () => {
|
||||
],
|
||||
writers: {
|
||||
lines: ['lines', {
|
||||
prefix: '//'
|
||||
prefix: '// '
|
||||
}],
|
||||
block: ['block', {
|
||||
start: '/*',
|
||||
@ -312,6 +311,7 @@ const CommentParser = () => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
console.log('comment?', comment);
|
||||
if ( ! comment ) break;
|
||||
results.push(comment);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
const levenshtein = require('js-levenshtein');
|
||||
const DiffMatchPatch = require('diff-match-patch');
|
||||
const enq = require('enquirer');
|
||||
const dmp = new DiffMatchPatch();
|
||||
const dedent = require('dedent');
|
||||
|
||||
@ -121,6 +122,8 @@ const LicenseChecker = ({
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
console.log('headers', headers);
|
||||
|
||||
const combined = headers_lines.slice(top, bottom).flat();
|
||||
const combined_txt = combined.join('\n');
|
||||
@ -130,6 +133,12 @@ const LicenseChecker = ({
|
||||
header2: combined_txt,
|
||||
})
|
||||
|
||||
if ( diff_info.distance > 0.7*desired_header.length ) {
|
||||
return {
|
||||
has_header: false,
|
||||
};
|
||||
}
|
||||
|
||||
diff_info.range = [
|
||||
headers[top].range[0],
|
||||
headers[bottom-1].range[1],
|
||||
@ -385,6 +394,18 @@ const cmd_sync_fn = async () => {
|
||||
if ( diff_info.distance !== 0 ) {
|
||||
counts.conflict++;
|
||||
process.stdout.write(`\x1B[31;1mCONFLICT\x1B[0m\n`);
|
||||
process.stdout.write('\x1B[36;1m=======\x1B[0m\n');
|
||||
process.stdout.write(diff_info.term_diff);
|
||||
process.stdout.write('\n\x1B[36;1m=======\x1B[0m\n');
|
||||
const prompt = new enq.Select({
|
||||
message: 'Select Action',
|
||||
choices: [
|
||||
{ name: 'skip', message: 'Skip' },
|
||||
{ name: 'replace', message: 'Replace' },
|
||||
]
|
||||
})
|
||||
const action = await prompt.run();
|
||||
console.log('action', action);
|
||||
} else {
|
||||
counts.ok++;
|
||||
process.stdout.write(`\x1B[32;1mOK\x1B[0m\n`);
|
||||
|
@ -13,6 +13,7 @@
|
||||
"console-table-printer": "^2.12.1",
|
||||
"dedent": "^1.5.3",
|
||||
"diff-match-patch": "^1.0.5",
|
||||
"enquirer": "^2.4.1",
|
||||
"js-levenshtein": "^1.1.6",
|
||||
"yaml": "^2.4.5"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user