make --patch available, remove cli sign

This commit is contained in:
dragonwocky 2021-12-28 02:31:44 +11:00
parent 94f1d9bf84
commit 4f0204aee3
Signed by: dragonwocky
GPG Key ID: 86DFC3C312A56010
5 changed files with 11 additions and 43 deletions

12
bin.mjs
View File

@ -37,7 +37,6 @@ const displayHelp = () => {
['apply', 'add enhancements to the notion app'], ['apply', 'add enhancements to the notion app'],
['remove', 'return notion to its pre-enhanced/pre-modded state'], ['remove', 'return notion to its pre-enhanced/pre-modded state'],
['check, status', 'check the current state of the notion app'], ['check, status', 'check the current state of the notion app'],
['sign', '[macos only] fix the "you do not have permission to open this app" error'],
], ],
options: [ options: [
['-y, --yes', 'skip prompts'], ['-y, --yes', 'skip prompts'],
@ -48,6 +47,7 @@ const displayHelp = () => {
'provide a file location to enhance (otherwise auto-picked)', 'provide a file location to enhance (otherwise auto-picked)',
], ],
['--no-backup', 'skip backup (faster enhancement, but disables removal)'], ['--no-backup', 'skip backup (faster enhancement, but disables removal)'],
['--patch', 'overwrite inserted files (useful for quick development/testing)'],
['-h, --help', 'display usage information'], ['-h, --help', 'display usage information'],
['-v, --version', 'display version number'], ['-v, --version', 'display version number'],
], ],
@ -105,8 +105,8 @@ try {
log`{bold.rgb(245,245,245) [NOTION-ENHANCER] APPLY}`; log`{bold.rgb(245,245,245) [NOTION-ENHANCER] APPLY}`;
const res = await apply(notionPath, { const res = await apply(notionPath, {
overwritePrevious: promptRes, overwritePrevious: promptRes,
patchPrevious: opts.get('patch') ? true : false,
takeBackup: opts.get('no-backup') ? false : true, takeBackup: opts.get('no-backup') ? false : true,
applyDevPatch: opts.get('dev-patch') ? true : false,
}); });
if (res) { if (res) {
log`{bold.rgb(245,245,245) SUCCESS} {green ✔}`; log`{bold.rgb(245,245,245) SUCCESS} {green ✔}`;
@ -135,14 +135,6 @@ try {
} }
break; break;
} }
case 'sign': {
log`{bold.rgb(245,245,245) [NOTION-ENHANCER] SIGN}`;
const res = await sign(notionPath);
if (res) {
log`{bold.rgb(245,245,245) SUCCESS} {green ✔}`;
} else log`{bold.rgb(245,245,245) CANCELLED} {red ✘}`;
break;
}
default: default:
displayHelp(); displayHelp();
} }

@ -1 +1 @@
Subproject commit 357cabe8657fddd53ca2ebdddbf4a64c833153ad Subproject commit ca25ae14aa61a31deedb2c6a97f72ad7e1ce1996

View File

@ -17,7 +17,7 @@ import remove from './remove.mjs';
export default async function ( export default async function (
notionFolder = findNotion(), notionFolder = findNotion(),
{ overwritePrevious = undefined, takeBackup = true, applyDevPatch = false } = {} { overwritePrevious = undefined, patchPrevious = false, takeBackup = true } = {}
) { ) {
let status = check(notionFolder); let status = check(notionFolder);
switch (status.code) { switch (status.code) {
@ -26,7 +26,7 @@ export default async function (
case 1: // corrupted case 1: // corrupted
throw Error(status.message); throw Error(status.message);
case 2: // same version already applied case 2: // same version already applied
if (!applyDevPatch) { if (!patchPrevious) {
log` {grey * notion-enhancer v${status.version} already applied}`; log` {grey * notion-enhancer v${status.version} already applied}`;
return true; return true;
} }

View File

@ -125,8 +125,12 @@ export const help = ({
if (version) version = ' v' + version; if (version) version = ' v' + version;
const cmdPad = Math.max(...commands.map((cmd) => cmd[0].length)), const cmdPad = Math.max(...commands.map((cmd) => cmd[0].length)),
optPad = Math.max(...options.map((opt) => opt[0].length)); optPad = Math.max(...options.map((opt) => opt[0].length));
commands = commands.map((cmd) => ` ${cmd[0].padEnd(cmdPad)} : ${cmd[1]}`).join('\n'); commands = commands
options = options.map((opt) => ` ${opt[0].padEnd(optPad)} : ${opt[1]}`).join('\n'); .map((cmd) => ` ${cmd[0].padEnd(cmdPad)} ${chalk`{grey :}`} ${cmd[1]}`)
.join('\n');
options = options
.map((opt) => ` ${opt[0].padEnd(optPad)} ${chalk`{grey :}`} ${opt[1]}`)
.join('\n');
log`{bold.rgb(245,245,245) ${name}${version}}`; log`{bold.rgb(245,245,245) ${name}${version}}`;
if (link) log`{grey ${link}}`; if (link) log`{grey ${link}}`;
log`\n{bold.rgb(245,245,245) USAGE}`; log`\n{bold.rgb(245,245,245) USAGE}`;

View File

@ -1,28 +0,0 @@
/**
* notion-enhancer
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license
*/
import { log } from './cli.mjs';
import { findNotion } from './helpers.mjs';
import { execSync } from 'child_process';
import check from './check.mjs';
export default async function (notionFolder = findNotion()) {
const status = check(notionFolder);
if (process.platform === 'darwin') {
log` {grey * app re-signing is only available on macos: exiting}`;
return false;
}
if (status.code > 1 && status.executable) {
log` {grey * installing xcode cli tools}`;
execSync('xcode-select --install');
log` {grey * codesigning app directory}`;
execSync(`codesign --force --deep --sign - ${status.installation}`);
} else log` {grey * enhancements not found: skipping}`;
return true;
}