mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-18 21:27:51 +00:00
Update oclif, improve help command
Change-type: minor
This commit is contained in:
parent
27ee9c85e7
commit
e46378ec51
@ -17,7 +17,7 @@
|
||||
|
||||
import type { JsonVersions } from '../lib/commands/version';
|
||||
|
||||
import { run as oclifRun } from 'oclif';
|
||||
import { run as oclifRun } from '@oclif/core';
|
||||
import * as archiver from 'archiver';
|
||||
import * as Bluebird from 'bluebird';
|
||||
import { execFile } from 'child_process';
|
||||
@ -30,6 +30,7 @@ import * as path from 'path';
|
||||
import * as rimraf from 'rimraf';
|
||||
import * as semver from 'semver';
|
||||
import { promisify } from 'util';
|
||||
import { notarize } from '@electron/notarize';
|
||||
|
||||
import { stripIndent } from '../build/utils/lazy';
|
||||
import {
|
||||
@ -206,7 +207,6 @@ async function buildPkg() {
|
||||
const paths: Array<[string, string[], string[]]> = [
|
||||
// [platform, [source path], [destination path]]
|
||||
['*', ['open', 'xdg-open'], ['xdg-open']],
|
||||
['*', ['opn', 'xdg-open'], ['xdg-open-402']],
|
||||
['darwin', ['denymount', 'bin', 'denymount'], ['denymount']],
|
||||
];
|
||||
await Promise.all(
|
||||
@ -471,8 +471,6 @@ async function notarizeMacInstaller(): Promise<void> {
|
||||
const appleIdPassword = process.env.XCODE_APP_LOADER_PASSWORD;
|
||||
|
||||
if (appleIdPassword && teamId) {
|
||||
const { notarize } = await import('@electron/notarize');
|
||||
// https://github.com/electron/notarize#readme
|
||||
await notarize({
|
||||
tool: 'notarytool',
|
||||
teamId,
|
||||
@ -494,9 +492,10 @@ export async function buildOclifInstaller() {
|
||||
let packOpts = ['-r', ROOT];
|
||||
if (process.platform === 'darwin') {
|
||||
packOS = 'macos';
|
||||
packOpts = packOpts.concat('--targets', 'darwin-x64');
|
||||
} else if (process.platform === 'win32') {
|
||||
packOS = 'win';
|
||||
packOpts = packOpts.concat('-t', 'win32-x64');
|
||||
packOpts = packOpts.concat('--targets', 'win32-x64');
|
||||
}
|
||||
if (packOS) {
|
||||
console.log(`Building oclif installer for CLI ${version}`);
|
||||
@ -514,10 +513,11 @@ export async function buildOclifInstaller() {
|
||||
await signFilesForNotarization();
|
||||
}
|
||||
console.log('=======================================================');
|
||||
console.log(`oclif "${packCmd}" "${packOpts.join('" "')}"`);
|
||||
console.log(`oclif ${packCmd} ${packOpts.join(' ')}`);
|
||||
console.log(`cwd="${process.cwd()}" ROOT="${ROOT}"`);
|
||||
console.log('=======================================================');
|
||||
await oclifRun([packCmd].concat(...packOpts));
|
||||
const oclifPath = path.join(ROOT, 'node_modules', 'oclif');
|
||||
await oclifRun([packCmd].concat(...packOpts), oclifPath);
|
||||
await renameInstallerFiles();
|
||||
// The Windows installer is explicitly signed here (oclif doesn't do it).
|
||||
// The macOS installer is automatically signed by oclif (which runs the
|
||||
|
18
lib/help.ts
18
lib/help.ts
@ -14,11 +14,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import Help from '@oclif/plugin-help';
|
||||
import { Help } from '@oclif/core';
|
||||
import { HelpFormatter } from '@oclif/core/lib/help/formatter';
|
||||
import * as indent from 'indent-string';
|
||||
import { getChalk } from './utils/lazy';
|
||||
import { renderList } from '@oclif/plugin-help/lib/list';
|
||||
import { ExpectedError } from './errors';
|
||||
|
||||
// Partially overrides standard implementation of help plugin
|
||||
// https://github.com/oclif/plugin-help/blob/master/src/index.ts
|
||||
@ -39,9 +38,11 @@ function getHelpSubject(args: string[]): string | undefined {
|
||||
}
|
||||
|
||||
export default class BalenaHelp extends Help {
|
||||
public helpFormatter = new HelpFormatter(this.config);
|
||||
|
||||
public static usage: 'help [command]';
|
||||
|
||||
public showHelp(argv: string[]) {
|
||||
public async showHelp(argv: string[]) {
|
||||
const chalk = getChalk();
|
||||
const subject = getHelpSubject(argv);
|
||||
if (!subject) {
|
||||
@ -52,7 +53,7 @@ export default class BalenaHelp extends Help {
|
||||
|
||||
const command = this.config.findCommand(subject);
|
||||
if (command) {
|
||||
this.showCommandHelp(command);
|
||||
await this.showCommandHelp(command);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -77,7 +78,7 @@ export default class BalenaHelp extends Help {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new ExpectedError(`command ${chalk.cyan.bold(subject)} not found`);
|
||||
console.log(`command ${chalk.cyan.bold(subject)} not found`);
|
||||
}
|
||||
|
||||
getCustomRootHelp(showAllCommands: boolean): string {
|
||||
@ -187,14 +188,15 @@ See: https://git.io/JRHUW#deprecation-policy`,
|
||||
return '';
|
||||
}
|
||||
|
||||
const body = renderList(
|
||||
const body = this.helpFormatter.renderList(
|
||||
commands
|
||||
.filter((c) => c.usage != null && c.usage !== '')
|
||||
.map((c) => [c.usage, this.formatDescription(c.description)]),
|
||||
{
|
||||
spacer: '\n',
|
||||
stripAnsi: this.opts.stripAnsi,
|
||||
maxWidth: this.opts.maxWidth - 2,
|
||||
indentation: 2,
|
||||
multiline: false,
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
import { Hook } from '@oclif/config';
|
||||
import type { IConfig } from '@oclif/config';
|
||||
import { getChalk } from '../../utils/lazy';
|
||||
|
||||
/*
|
||||
A modified version of the command-not-found plugin logic,
|
||||
@ -31,7 +32,7 @@ const hook: Hook<'command-not-found'> = async function (
|
||||
) {
|
||||
const Levenshtein = await import('fast-levenshtein');
|
||||
const _ = await import('lodash');
|
||||
const { color } = await import('@oclif/color');
|
||||
const chalk = getChalk();
|
||||
|
||||
const commandId = opts.id || '';
|
||||
const command = opts.id?.replace(':', ' ') || '';
|
||||
@ -60,17 +61,19 @@ const hook: Hook<'command-not-found'> = async function (
|
||||
|
||||
// Output suggestions
|
||||
console.error(
|
||||
`${color.yellow(command)} is not a recognized balena command.\n`,
|
||||
`${chalk.yellow(command)} is not a recognized balena command.\n`,
|
||||
);
|
||||
console.error(`Did you mean: ? `);
|
||||
suggestions.forEach((s) => {
|
||||
console.error(` ${color.cmd(s)}`);
|
||||
console.error(` ${chalk.cyan.bold(s)}`);
|
||||
});
|
||||
console.error(
|
||||
`\nRun ${color.cmd('balena help -v')} for a list of available commands,`,
|
||||
`\nRun ${chalk.cyan.bold(
|
||||
'balena help -v',
|
||||
)} for a list of available commands,`,
|
||||
);
|
||||
console.error(
|
||||
` or ${color.cmd(
|
||||
` or ${chalk.cyan.bold(
|
||||
'balena help <command>',
|
||||
)} for detailed help on a specific command.`,
|
||||
);
|
||||
|
@ -20,7 +20,7 @@ import type * as BalenaSdk from 'balena-sdk';
|
||||
import type { Chalk } from 'chalk';
|
||||
import type * as visuals from 'resin-cli-visuals';
|
||||
import type * as CliForm from 'resin-cli-form';
|
||||
import type { ux } from 'cli-ux';
|
||||
import type { ux } from '@oclif/core';
|
||||
|
||||
// Equivalent of _.once but avoiding the need to import lodash for lazy deps
|
||||
const once = <T>(fn: () => T) => {
|
||||
@ -57,7 +57,9 @@ export const getCliForm = once(
|
||||
() => require('resin-cli-form') as typeof CliForm,
|
||||
);
|
||||
|
||||
export const getCliUx = once(() => require('cli-ux').ux as typeof ux);
|
||||
export const getCliUx = once(
|
||||
() => require('@oclif/core/lib/cli-ux') as typeof ux,
|
||||
);
|
||||
|
||||
// Directly export stripIndent as we always use it immediately, but importing just `stripIndent` reduces startup time
|
||||
export const stripIndent =
|
||||
|
18754
npm-shrinkwrap.json
generated
18754
npm-shrinkwrap.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@ -36,7 +36,6 @@
|
||||
"node_modules/balena-sdk/node_modules/balena-pine/**/*",
|
||||
"node_modules/balena-pine/**/*",
|
||||
"node_modules/pinejs-client-core/**/*",
|
||||
"node_modules/opn/xdg-open",
|
||||
"node_modules/open/xdg-open",
|
||||
"node_modules/windosu/*.bat",
|
||||
"node_modules/windosu/*.cmd",
|
||||
@ -107,10 +106,7 @@
|
||||
"macos": {
|
||||
"identifier": "io.balena.cli",
|
||||
"sign": "Developer ID Installer: Balena Ltd (66H43P8FRG)"
|
||||
},
|
||||
"plugins": [
|
||||
"@oclif/plugin-help"
|
||||
]
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@balena/lint": "^6.2.2",
|
||||
@ -190,6 +186,7 @@
|
||||
"simple-git": "^3.14.1",
|
||||
"sinon": "^11.1.2",
|
||||
"ts-node": "^10.4.0",
|
||||
"oclif": "^3.9.1",
|
||||
"typescript": "^5.1.3"
|
||||
},
|
||||
"dependencies": {
|
||||
@ -197,6 +194,7 @@
|
||||
"@balena/dockerignore": "^1.0.2",
|
||||
"@balena/es-version": "^1.0.1",
|
||||
"@oclif/command": "^1.8.16",
|
||||
"@oclif/core": "^2.15.0",
|
||||
"@resin.io/valid-email": "^0.1.0",
|
||||
"@sentry/node": "^6.16.1",
|
||||
"@types/fast-levenshtein": "0.0.1",
|
||||
@ -216,7 +214,6 @@
|
||||
"chalk": "^3.0.0",
|
||||
"chokidar": "^3.5.2",
|
||||
"cli-truncate": "^2.1.0",
|
||||
"cli-ux": "^5.5.1",
|
||||
"color-hash": "^1.1.1",
|
||||
"columnify": "^1.5.2",
|
||||
"common-tags": "^1.7.2",
|
||||
@ -252,7 +249,6 @@
|
||||
"net-keepalive": "^3.0.0",
|
||||
"node-cleanup": "^2.1.2",
|
||||
"node-unzip-2": "^0.2.8",
|
||||
"oclif": "^1.18.4",
|
||||
"open": "^7.1.0",
|
||||
"patch-package": "^6.4.7",
|
||||
"prettyjson": "^1.2.5",
|
||||
|
49
patches/all/@oclif+core+2.15.0.patch
Normal file
49
patches/all/@oclif+core+2.15.0.patch
Normal file
@ -0,0 +1,49 @@
|
||||
diff --git a/node_modules/@oclif/core/lib/help/command.js b/node_modules/@oclif/core/lib/help/command.js
|
||||
index 6de139b..3a13197 100644
|
||||
--- a/node_modules/@oclif/core/lib/help/command.js
|
||||
+++ b/node_modules/@oclif/core/lib/help/command.js
|
||||
@@ -206,7 +206,7 @@ class CommandHelp extends formatter_1.HelpFormatter {
|
||||
if (args.filter(a => a.description).length === 0)
|
||||
return;
|
||||
return args.map(a => {
|
||||
- const name = a.name.toUpperCase();
|
||||
+ const name = a.required ? `<${a.name}>` : `[${a.name}]`;
|
||||
let description = a.description || '';
|
||||
if (a.default)
|
||||
description = `[default: ${a.default}] ${description}`;
|
||||
@@ -238,14 +238,12 @@ class CommandHelp extends formatter_1.HelpFormatter {
|
||||
label = labels.join(', ');
|
||||
}
|
||||
if (flag.type === 'option') {
|
||||
- let value = flag.helpValue || (this.opts.showFlagNameInTitle ? flag.name : '<value>');
|
||||
+ let value = flag.helpValue || (this.opts.showFlagNameInTitle ? flag.name : `<${flag.name}>`);
|
||||
if (!flag.helpValue && flag.options) {
|
||||
value = showOptions || this.opts.showFlagOptionsInTitle ? `${flag.options.join('|')}` : '<option>';
|
||||
}
|
||||
if (flag.multiple)
|
||||
- value += '...';
|
||||
- if (!value.includes('|'))
|
||||
- value = underline(value);
|
||||
+ value += ' ...';
|
||||
label += `=${value}`;
|
||||
}
|
||||
return label;
|
||||
diff --git a/node_modules/@oclif/core/lib/help/index.js b/node_modules/@oclif/core/lib/help/index.js
|
||||
index f9ef7cc..a14c67c 100644
|
||||
--- a/node_modules/@oclif/core/lib/help/index.js
|
||||
+++ b/node_modules/@oclif/core/lib/help/index.js
|
||||
@@ -136,11 +136,12 @@ class Help extends HelpBase {
|
||||
}
|
||||
this.log(this.formatCommand(command));
|
||||
this.log('');
|
||||
- if (subTopics.length > 0) {
|
||||
+ const SUPPRESS_SUBTOPICS = true;
|
||||
+ if (subTopics.length > 0 && !SUPPRESS_SUBTOPICS) {
|
||||
this.log(this.formatTopics(subTopics));
|
||||
this.log('');
|
||||
}
|
||||
- if (subCommands.length > 0) {
|
||||
+ if (subCommands.length > 0 && !SUPPRESS_SUBTOPICS) {
|
||||
const aliases = [];
|
||||
const uniqueSubCommands = subCommands.filter(p => {
|
||||
aliases.push(...p.aliases);
|
@ -1,43 +0,0 @@
|
||||
diff --git a/node_modules/@oclif/plugin-help/lib/command.js b/node_modules/@oclif/plugin-help/lib/command.js
|
||||
index b3b9010..788e5c6 100644
|
||||
--- a/node_modules/@oclif/plugin-help/lib/command.js
|
||||
+++ b/node_modules/@oclif/plugin-help/lib/command.js
|
||||
@@ -88,7 +88,7 @@ class CommandHelp {
|
||||
return;
|
||||
const body = list_1.renderList(args.map(a => {
|
||||
var _a;
|
||||
- const name = a.name.toUpperCase();
|
||||
+ const name = a.required ? `<${a.name}>` : `[${a.name}]`;
|
||||
let description = a.description || '';
|
||||
// `a.default` is actually not always a string (typing bug), hence `toString()`
|
||||
if (a.default || ((_a = a.default) === null || _a === void 0 ? void 0 : _a.toString()) === '0')
|
||||
@@ -133,9 +133,7 @@ class CommandHelp {
|
||||
if (!flag.helpValue && flag.options) {
|
||||
value = flag.options.join('|');
|
||||
}
|
||||
- if (!value.includes('|'))
|
||||
- value = underline(value);
|
||||
- left += `=${value}`;
|
||||
+ left += ` <${value}>`;
|
||||
}
|
||||
let right = flag.description || '';
|
||||
// `flag.default` is not always a string (typing bug), hence `toString()`
|
||||
diff --git a/node_modules/@oclif/plugin-help/lib/index.js b/node_modules/@oclif/plugin-help/lib/index.js
|
||||
index 04d7861..c2fb591 100644
|
||||
--- a/node_modules/@oclif/plugin-help/lib/index.js
|
||||
+++ b/node_modules/@oclif/plugin-help/lib/index.js
|
||||
@@ -98,11 +98,12 @@ class Help extends HelpBase {
|
||||
console.log(title + '\n');
|
||||
console.log(this.formatCommand(command));
|
||||
console.log('');
|
||||
- if (subTopics.length > 0) {
|
||||
+ const SUPPRESS_SUBTOPICS = true;
|
||||
+ if (subTopics.length > 0 && !SUPPRESS_SUBTOPICS) {
|
||||
console.log(this.formatTopics(subTopics));
|
||||
console.log('');
|
||||
}
|
||||
- if (subCommands.length > 0) {
|
||||
+ if (subCommands.length > 0 && !SUPPRESS_SUBTOPICS) {
|
||||
console.log(this.formatCommands(subCommands));
|
||||
console.log('');
|
||||
}
|
@ -1,278 +0,0 @@
|
||||
diff --git a/node_modules/oclif/lib/commands/pack/macos.js b/node_modules/oclif/lib/commands/pack/macos.js
|
||||
index 924f092..a69e60b 100644
|
||||
--- a/node_modules/oclif/lib/commands/pack/macos.js
|
||||
+++ b/node_modules/oclif/lib/commands/pack/macos.js
|
||||
@@ -133,6 +133,7 @@ class PackMacos extends command_1.Command {
|
||||
if (process.env.OSX_KEYCHAIN)
|
||||
args.push('--keychain', process.env.OSX_KEYCHAIN);
|
||||
args.push(dist);
|
||||
+ console.error(`[debug] oclif pkgbuild "${args.join('" "')}"`);
|
||||
await qq.x('pkgbuild', args);
|
||||
}
|
||||
}
|
||||
diff --git a/node_modules/oclif/lib/commands/pack/win.js b/node_modules/oclif/lib/commands/pack/win.js
|
||||
index bf4657e..fd58c7d 100644
|
||||
--- a/node_modules/oclif/lib/commands/pack/win.js
|
||||
+++ b/node_modules/oclif/lib/commands/pack/win.js
|
||||
@@ -52,6 +52,13 @@ VIAddVersionKey /LANG=\${LANG_ENGLISH} "ProductVersion" "\${VERSION}.0"
|
||||
InstallDir "\$PROGRAMFILES${arch === 'x64' ? '64' : ''}\\${config.dirname}"
|
||||
|
||||
Section "${config.name} CLI \${VERSION}"
|
||||
+ ; First remove any old client files.
|
||||
+ ; (Remnants of old versions were causing CLI errors)
|
||||
+ ; Initially tried running the Uninstall.exe, but was
|
||||
+ ; unable to make script wait for completion (despite using _?)
|
||||
+ DetailPrint "Removing files from previous version."
|
||||
+ RMDir /r "$INSTDIR\\client"
|
||||
+
|
||||
SetOutPath $INSTDIR
|
||||
File /r bin
|
||||
File /r client
|
||||
@@ -61,6 +68,8 @@ Section "${config.name} CLI \${VERSION}"
|
||||
WriteUninstaller "$INSTDIR\\Uninstall.exe"
|
||||
WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${config.dirname}" \\
|
||||
"DisplayName" "${config.name}"
|
||||
+ WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${config.dirname}" \\
|
||||
+ "DisplayVersion" "\${VERSION}"
|
||||
WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${config.dirname}" \\
|
||||
"UninstallString" "$\\"$INSTDIR\\uninstall.exe$\\""
|
||||
WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${config.dirname}" \\
|
||||
@@ -193,7 +202,8 @@ class PackWin extends command_1.Command {
|
||||
async run() {
|
||||
await this.checkForNSIS();
|
||||
const { flags } = this.parse(PackWin);
|
||||
- const buildConfig = await Tarballs.buildConfig(flags.root);
|
||||
+ const $targets = flags.targets ? flags.targets.split(',') : undefined;
|
||||
+ const buildConfig = await Tarballs.buildConfig(flags.root, { targets: $targets });
|
||||
const { config, version, gitSha, targets, tmp } = buildConfig;
|
||||
await Tarballs.build(buildConfig, { platform: 'win32', pack: false });
|
||||
const arches = targets.filter(t => t.platform === 'win32').map(t => t.arch);
|
||||
@@ -208,7 +218,8 @@ class PackWin extends command_1.Command {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await qq.mv(buildConfig.workspace({ platform: 'win32', arch }), [installerBase, 'client']);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
- await qq.x(`makensis ${installerBase}/${config.bin}.nsi | grep -v "\\[compress\\]" | grep -v "^File: Descending to"`);
|
||||
+ const { msysExec, toMsysPath } = require("../../util");
|
||||
+ await msysExec(`makensis ${toMsysPath(installerBase)}/${config.bin}.nsi | grep -v "\\[compress\\]" | grep -v "^File: Descending to"`);
|
||||
const templateKey = upload_util_1.templateShortKey('win32', { bin: config.bin, version: version, sha: gitSha, arch });
|
||||
const o = buildConfig.dist(`win32/${templateKey}`);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
@@ -255,4 +266,5 @@ PackWin.hidden = true;
|
||||
PackWin.description = 'create windows installer from oclif CLI';
|
||||
PackWin.flags = {
|
||||
root: command_1.flags.string({ char: 'r', description: 'path to oclif CLI root', default: '.', required: true }),
|
||||
+ targets: command_1.flags.string({char: 't', description: 'comma-separated targets to pack (e.g.: win32-x86,win32-x64)'}),
|
||||
};
|
||||
diff --git a/node_modules/oclif/lib/tarballs/build.js b/node_modules/oclif/lib/tarballs/build.js
|
||||
index d3e8e89..a5d29e2 100644
|
||||
--- a/node_modules/oclif/lib/tarballs/build.js
|
||||
+++ b/node_modules/oclif/lib/tarballs/build.js
|
||||
@@ -18,8 +18,9 @@ const pack = async (from, to) => {
|
||||
qq.cd(prevCwd);
|
||||
};
|
||||
async function build(c, options = {}) {
|
||||
- const { xz, config, version, s3Config, gitSha, nodeVersion, targets, updateConfig } = c;
|
||||
+ const { xz, config, version, s3Config, gitSha, nodeVersion, targets, updateConfig, tmp } = c;
|
||||
const prevCwd = qq.cwd();
|
||||
+ console.error(`[debug] oclif cwd="${prevCwd}"\n c.root="${c.root}" c.workspace()="${c.workspace()}"`);
|
||||
const packCLI = async () => {
|
||||
const stdout = await qq.x.stdout('npm', ['pack', '--unsafe-perm'], { cwd: c.root });
|
||||
return path.join(c.root, stdout.split('\n').pop());
|
||||
@@ -30,11 +31,19 @@ async function build(c, options = {}) {
|
||||
tarball = path.basename(tarball);
|
||||
tarball = qq.join([c.workspace(), tarball]);
|
||||
qq.cd(c.workspace());
|
||||
- await qq.x(`tar -xzf ${tarball}`);
|
||||
+ const { msysExec, toMsysPath } = require("../util");
|
||||
+ await msysExec(`tar -xzf ${toMsysPath(tarball)}`);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
for (const f of await qq.ls('package', { fullpath: true }))
|
||||
await qq.mv(f, '.');
|
||||
await qq.rm('package', tarball, 'bin/run.cmd');
|
||||
+ // rename the original balena-cli ./bin/balena entry point for oclif compatibility
|
||||
+ await qq.mv('bin/balena', 'bin/run');
|
||||
+ // The oclif installers are a production installation, while the source
|
||||
+ // `bin` folder may contain a `.fast-boot.json` file of a dev installation.
|
||||
+ // This has previously led to issues preventing the CLI from starting, so
|
||||
+ // delete `.fast-boot.json` (if any) from the destination folder.
|
||||
+ await qq.rm('bin/.fast-boot.json');
|
||||
};
|
||||
const updatePJSON = async () => {
|
||||
qq.cd(c.workspace());
|
||||
@@ -46,21 +55,21 @@ async function build(c, options = {}) {
|
||||
await qq.writeJSON('package.json', pjson);
|
||||
};
|
||||
const addDependencies = async () => {
|
||||
- qq.cd(c.workspace());
|
||||
- const yarnRoot = findYarnWorkspaceRoot(c.root) || c.root;
|
||||
- const yarn = await qq.exists([yarnRoot, 'yarn.lock']);
|
||||
- if (yarn) {
|
||||
- await qq.cp([yarnRoot, 'yarn.lock'], '.');
|
||||
- await qq.x('yarn --no-progress --production --non-interactive');
|
||||
- }
|
||||
- else {
|
||||
- let lockpath = qq.join(c.root, 'package-lock.json');
|
||||
- if (!await qq.exists(lockpath)) {
|
||||
- lockpath = qq.join(c.root, 'npm-shrinkwrap.json');
|
||||
- }
|
||||
- await qq.cp(lockpath, '.');
|
||||
- await qq.x('npm install --production');
|
||||
+ const ws = c.workspace();
|
||||
+ qq.cd(ws);
|
||||
+ console.error(`[debug] oclif copying node_modules to "${ws}"`)
|
||||
+ const source = path.join(c.root, 'node_modules');
|
||||
+ if (process.platform === 'win32') {
|
||||
+ // xcopy is much faster than `qq.cp(source, ws)`
|
||||
+ await qq.x(`xcopy "${source}" "${ws}\\node_modules" /S /E /B /I /K /Q /Y`);
|
||||
+ } else {
|
||||
+ // use the shell's `cp` on macOS in order to preserve extended
|
||||
+ // file attributes containing `codesign` digital signatures
|
||||
+ await qq.x(`cp -pR "${source}" "${ws}"`);
|
||||
}
|
||||
+ console.error(`[debug] oclif running "npm prune --production" in "${ws}"`);
|
||||
+ await qq.x('npm prune --production');
|
||||
+ console.error(`[debug] oclif done`);
|
||||
};
|
||||
const pretarball = async () => {
|
||||
qq.cd(c.workspace());
|
||||
@@ -99,7 +108,8 @@ async function build(c, options = {}) {
|
||||
output: path.join(workspace, 'bin', 'node'),
|
||||
platform: target.platform,
|
||||
arch: target.arch,
|
||||
- tmp: qq.join(config.root, 'tmp'),
|
||||
+ tmp,
|
||||
+ projectRootPath: c.root,
|
||||
});
|
||||
if (options.pack === false)
|
||||
return;
|
||||
diff --git a/node_modules/oclif/lib/tarballs/config.js b/node_modules/oclif/lib/tarballs/config.js
|
||||
index 0dc3cd7..1336219 100644
|
||||
--- a/node_modules/oclif/lib/tarballs/config.js
|
||||
+++ b/node_modules/oclif/lib/tarballs/config.js
|
||||
@@ -18,7 +18,10 @@ function gitSha(cwd, options = {}) {
|
||||
}
|
||||
exports.gitSha = gitSha;
|
||||
async function Tmp(config) {
|
||||
- const tmp = path.join(config.root, 'tmp');
|
||||
+ const tmp = process.env.BUILD_TMP
|
||||
+ ? path.join(process.env.BUILD_TMP, 'oclif')
|
||||
+ : path.join(config.root, 'tmp');
|
||||
+ console.error(`[debug] oclif tmp="${tmp}"`);
|
||||
await qq.mkdirp(tmp);
|
||||
return tmp;
|
||||
}
|
||||
@@ -43,7 +46,7 @@ async function buildConfig(root, options = {}) {
|
||||
s3Config: updateConfig.s3,
|
||||
nodeVersion: updateConfig.node.version || process.versions.node,
|
||||
workspace(target) {
|
||||
- const base = qq.join(config.root, 'tmp');
|
||||
+ const base = tmp;
|
||||
if (target && target.platform)
|
||||
return qq.join(base, [target.platform, target.arch].join('-'), upload_util_1.templateShortKey('baseDir', { bin: config.bin }));
|
||||
return qq.join(base, upload_util_1.templateShortKey('baseDir', { bin: config.bin }));
|
||||
diff --git a/node_modules/oclif/lib/tarballs/node.js b/node_modules/oclif/lib/tarballs/node.js
|
||||
index fabe5c4..e32dd76 100644
|
||||
--- a/node_modules/oclif/lib/tarballs/node.js
|
||||
+++ b/node_modules/oclif/lib/tarballs/node.js
|
||||
@@ -4,9 +4,10 @@ const errors_1 = require("@oclif/errors");
|
||||
const path = require("path");
|
||||
const qq = require("qqjs");
|
||||
const log_1 = require("../log");
|
||||
+const { isMSYS2, msysExec, toMsysPath } = require("../util");
|
||||
async function checkFor7Zip() {
|
||||
try {
|
||||
- await qq.x('7z', { stdio: [0, null, 2] });
|
||||
+ await msysExec('7z', { stdio: [0, null, 2] });
|
||||
}
|
||||
catch (error) {
|
||||
if (error.code === 127)
|
||||
@@ -41,7 +42,8 @@ async function fetchNodeBinary({ nodeVersion, output, platform, arch, tmp }) {
|
||||
const basedir = path.dirname(tarball);
|
||||
await qq.mkdirp(basedir);
|
||||
await qq.download(url, tarball);
|
||||
- await qq.x(`grep ${path.basename(tarball)} ${shasums} | shasum -a 256 -c -`, { cwd: basedir });
|
||||
+ const shaCmd = isMSYS2 ? 'sha256sum -c -' : 'shasum -a 256 -c -';
|
||||
+ await msysExec(`grep ${path.basename(tarball)} ${toMsysPath(shasums)} | ${shaCmd}`, { cwd: basedir });
|
||||
};
|
||||
const extract = async () => {
|
||||
log_1.log(`extracting ${nodeBase}`);
|
||||
@@ -51,7 +53,7 @@ async function fetchNodeBinary({ nodeVersion, output, platform, arch, tmp }) {
|
||||
await qq.mkdirp(path.dirname(cache));
|
||||
if (platform === 'win32') {
|
||||
qq.pushd(nodeTmp);
|
||||
- await qq.x(`7z x -bd -y ${tarball} > /dev/null`);
|
||||
+ await msysExec(`7z x -bd -y ${toMsysPath(tarball)} > /dev/null`);
|
||||
await qq.mv([nodeBase, 'node.exe'], cache);
|
||||
qq.popd();
|
||||
}
|
||||
diff --git a/node_modules/oclif/lib/upload-util.js b/node_modules/oclif/lib/upload-util.js
|
||||
index 45392cb..3c806c7 100644
|
||||
--- a/node_modules/oclif/lib/upload-util.js
|
||||
+++ b/node_modules/oclif/lib/upload-util.js
|
||||
@@ -28,10 +28,10 @@ function templateShortKey(type, ext, options = { root: '.' }) {
|
||||
const templates = {
|
||||
baseDir: '<%- bin %>',
|
||||
unversioned: '<%- bin %>-<%- platform %>-<%- arch %><%- ext %>',
|
||||
- versioned: '<%- bin %>-v<%- version %>-<%- sha %>-<%- platform %>-<%- arch %><%- ext %>',
|
||||
- manifest: '<%- bin %>-v<%- version %>-<%- sha %>-<%- platform %>-<%- arch %>-buildmanifest',
|
||||
- macos: '<%- bin %>-v<%- version %>-<%- sha %>.pkg',
|
||||
- win32: '<%- bin %>-v<%- version %>-<%- sha %>-<%- arch %>.exe',
|
||||
+ versioned: '<%- bin %>-v<%- version %>-<%- platform %>-<%- arch %><%- ext %>',
|
||||
+ manifest: '<%- bin %>-v<%- version %>-<%- platform %>-<%- arch %>-buildmanifest',
|
||||
+ macos: '<%- bin %>-v<%- version %>.pkg',
|
||||
+ win32: '<%- bin %>-v<%- version %>-<%- arch %>.exe',
|
||||
deb: '<%- bin %>_<%- versionShaRevision %>_<%- arch %>.deb',
|
||||
};
|
||||
return _.template(templates[type])(Object.assign({}, options));
|
||||
diff --git a/node_modules/oclif/lib/util.js b/node_modules/oclif/lib/util.js
|
||||
index 17748ad..4928fc9 100644
|
||||
--- a/node_modules/oclif/lib/util.js
|
||||
+++ b/node_modules/oclif/lib/util.js
|
||||
@@ -67,3 +67,47 @@ exports.sortVersionsObjectByKeysDesc = (input) => {
|
||||
}
|
||||
return result;
|
||||
};
|
||||
+
|
||||
+// OSTYPE is 'msys' for MSYS 1.0 and for MSYS2, or 'cygwin' for Cygwin
|
||||
+// but note that OSTYPE is not "exported" by default, so run: export OSTYPE=$OSTYPE
|
||||
+// MSYSTEM is 'MINGW32' for MSYS 1.0, 'MSYS' for MSYS2, and undefined for Cygwin
|
||||
+const isCygwin = process.env.OSTYPE === 'cygwin';
|
||||
+const isMinGW = process.env.MSYSTEM && process.env.MSYSTEM.startsWith('MINGW');
|
||||
+const isMSYS2 = process.env.MSYSTEM && process.env.MSYSTEM.startsWith('MSYS');
|
||||
+const MSYSSHELLPATH = process.env.MSYSSHELLPATH ||
|
||||
+ (isMSYS2 ? 'C:\\msys64\\usr\\bin\\bash.exe' :
|
||||
+ (isMinGW ? 'C:\\MinGW\\msys\\1.0\\bin\\bash.exe' :
|
||||
+ (isCygwin ? 'C:\\cygwin64\\bin\\bash.exe' : '/bin/sh')));
|
||||
+
|
||||
+exports.isCygwin = isCygwin;
|
||||
+exports.isMinGW = isMinGW;
|
||||
+exports.isMSYS2 = isMSYS2;
|
||||
+console.error(`[debug] oclif MSYSSHELLPATH=${MSYSSHELLPATH} MSYSTEM=${process.env.MSYSTEM} OSTYPE=${process.env.OSTYPE} isMSYS2=${isMSYS2} isMingGW=${isMinGW} isCygwin=${isCygwin}`);
|
||||
+
|
||||
+const qq = require("qqjs");
|
||||
+
|
||||
+/* Convert a Windows path like 'C:\tmp' to a MSYS path like '/c/tmp' */
|
||||
+function toMsysPath(windowsPath) {
|
||||
+ // 'c:\myfolder' -> '/c/myfolder' or '/cygdrive/c/myfolder'
|
||||
+ let msysPath = windowsPath.replace(/\\/g, '/');
|
||||
+ if (isMSYS2 || isMinGW) {
|
||||
+ msysPath = msysPath.replace(/^([a-zA-Z]):/, '/$1');
|
||||
+ } else if (isCygwin) {
|
||||
+ msysPath = msysPath.replace(/^([a-zA-Z]):/, '/cygdrive/$1');
|
||||
+ }
|
||||
+ console.error(`[debug] oclif toMsysPath before="${windowsPath}" after="${msysPath}"`);
|
||||
+ return msysPath;
|
||||
+}
|
||||
+exports.toMsysPath = toMsysPath;
|
||||
+
|
||||
+/* Like qqjs qq.x(), but using MSYS bash on Windows instead of cmd.exe */
|
||||
+async function msysExec(cmd, options = {}) {
|
||||
+ if (process.platform !== 'win32') {
|
||||
+ return qq.x(cmd, options);
|
||||
+ }
|
||||
+ const sh = MSYSSHELLPATH;
|
||||
+ const args = ['-c', cmd];
|
||||
+ console.error(`[debug] oclif msysExec sh="${sh}" args=${JSON.stringify(args)} options=${JSON.stringify(options)}`);
|
||||
+ return qq.x(sh, args, options);
|
||||
+}
|
||||
+exports.msysExec = msysExec;
|
307
patches/all/oclif+3.11.3.patch
Normal file
307
patches/all/oclif+3.11.3.patch
Normal file
@ -0,0 +1,307 @@
|
||||
diff --git a/node_modules/oclif/lib/commands/pack/macos.js b/node_modules/oclif/lib/commands/pack/macos.js
|
||||
index d06d0b3..c571fe3 100644
|
||||
--- a/node_modules/oclif/lib/commands/pack/macos.js
|
||||
+++ b/node_modules/oclif/lib/commands/pack/macos.js
|
||||
@@ -177,7 +177,8 @@ class PackMacos extends core_1.Command {
|
||||
if (process.env.OSX_KEYCHAIN)
|
||||
args.push('--keychain', process.env.OSX_KEYCHAIN);
|
||||
args.push(dist);
|
||||
- await exec(`pkgbuild ${args.join(' ')}`);
|
||||
+ console.error(`[debug] oclif pkgbuild "${args.join('" "')}"`);
|
||||
+ await exec(`pkgbuild "${args.join('" "')}"`);
|
||||
};
|
||||
const arches = _.uniq(buildConfig.targets
|
||||
.filter(t => t.platform === 'darwin')
|
||||
diff --git a/node_modules/oclif/lib/commands/pack/win.js b/node_modules/oclif/lib/commands/pack/win.js
|
||||
index 360c34b..ae14bf5 100644
|
||||
--- a/node_modules/oclif/lib/commands/pack/win.js
|
||||
+++ b/node_modules/oclif/lib/commands/pack/win.js
|
||||
@@ -59,6 +59,13 @@ InstallDir "\$PROGRAMFILES${arch === 'x64' ? '64' : ''}\\${config.dirname}"
|
||||
${customization}
|
||||
|
||||
Section "${config.name} CLI \${VERSION}"
|
||||
+ ; First remove any old client files.
|
||||
+ ; (Remnants of old versions were causing CLI errors)
|
||||
+ ; Initially tried running the Uninstall.exe, but was
|
||||
+ ; unable to make script wait for completion (despite using _?)
|
||||
+ DetailPrint "Removing files from previous version."
|
||||
+ RMDir /r "$INSTDIR\\client"
|
||||
+
|
||||
SetOutPath $INSTDIR
|
||||
File /r bin
|
||||
File /r client
|
||||
@@ -203,7 +210,8 @@ class PackWin extends core_1.Command {
|
||||
async run() {
|
||||
await this.checkForNSIS();
|
||||
const { flags } = await this.parse(PackWin);
|
||||
- const buildConfig = await Tarballs.buildConfig(flags.root);
|
||||
+ const $targets = flags.targets ? flags.targets.split(',') : undefined;
|
||||
+ const buildConfig = await Tarballs.buildConfig(flags.root, { targets: $targets });
|
||||
const { config } = buildConfig;
|
||||
await Tarballs.build(buildConfig, { platform: 'win32', pack: false, tarball: flags.tarball, parallel: true });
|
||||
const arches = buildConfig.targets.filter(t => t.platform === 'win32').map(t => t.arch);
|
||||
@@ -225,7 +233,8 @@ class PackWin extends core_1.Command {
|
||||
fs.writeFile(path.join(installerBase, 'bin', `${flags['additional-cli']}`), scripts.sh({ bin: flags['additional-cli'] })),
|
||||
] : []));
|
||||
await fs.move(buildConfig.workspace({ platform: 'win32', arch }), path.join(installerBase, 'client'));
|
||||
- await exec(`makensis ${installerBase}/${config.bin}.nsi | grep -v "\\[compress\\]" | grep -v "^File: Descending to"`);
|
||||
+ const { msysExec, toMsysPath } = require("../../util");
|
||||
+ await msysExec(`makensis ${toMsysPath(installerBase)}/${config.bin}.nsi | grep -v "\\[compress\\]" | grep -v "^File: Descending to"`);
|
||||
const templateKey = (0, upload_util_1.templateShortKey)('win32', { bin: config.bin, version: config.version, sha: buildConfig.gitSha, arch });
|
||||
const o = buildConfig.dist(`win32/${templateKey}`);
|
||||
await fs.move(path.join(installerBase, 'installer.exe'), o);
|
||||
@@ -263,6 +272,9 @@ PackWin.flags = {
|
||||
default: '.',
|
||||
required: true,
|
||||
}),
|
||||
+ targets: core_1.Flags.string({
|
||||
+ description: 'comma-separated targets to pack (e.g.: win32-x86,win32-x64)'
|
||||
+ }),
|
||||
'additional-cli': core_1.Flags.string({
|
||||
description: `an Oclif CLI other than the one listed in config.bin that should be made available to the user
|
||||
the CLI should already exist in a directory named after the CLI that is the root of the tarball produced by "oclif pack:tarballs"`,
|
||||
diff --git a/node_modules/oclif/lib/tarballs/build.js b/node_modules/oclif/lib/tarballs/build.js
|
||||
index 384ea4b..41963eb 100644
|
||||
--- a/node_modules/oclif/lib/tarballs/build.js
|
||||
+++ b/node_modules/oclif/lib/tarballs/build.js
|
||||
@@ -21,8 +21,10 @@ const pack = async (from, to) => {
|
||||
await exec(`tar cfJ ${to} ${(path.basename(from))}`, { cwd }));
|
||||
};
|
||||
async function build(c, options = {}) {
|
||||
- const { xz, config } = c;
|
||||
+ const { xz, config, tmp } = c;
|
||||
+ console.error(`[debug] oclif c.root="${c.root}" c.workspace()="${c.workspace()}"`);
|
||||
const packCLI = async () => {
|
||||
+ console.error('[debug] packing cli');
|
||||
const { stdout } = await exec('npm pack --unsafe-perm', { cwd: c.root });
|
||||
return path.join(c.root, stdout.trim().split('\n').pop());
|
||||
};
|
||||
@@ -30,7 +32,8 @@ async function build(c, options = {}) {
|
||||
await fs.emptyDir(c.workspace());
|
||||
const tarballNewLocation = path.join(c.workspace(), path.basename(tarball));
|
||||
await fs.move(tarball, tarballNewLocation);
|
||||
- await exec(`tar -xzf "${tarballNewLocation}"`, { cwd: c.workspace() });
|
||||
+ const { msysExec, toMsysPath } = require("../util");
|
||||
+ await msysExec(`tar -xzf ${toMsysPath(tarballNewLocation)}`, { cwd: c.workspace() });
|
||||
await Promise.all((await fs.promises.readdir(path.join(c.workspace(), 'package'), { withFileTypes: true }))
|
||||
.map(i => fs.move(path.join(c.workspace(), 'package', i.name), path.join(c.workspace(), i.name))));
|
||||
await Promise.all([
|
||||
@@ -38,6 +41,13 @@ async function build(c, options = {}) {
|
||||
fs.promises.rm(path.join(c.workspace(), path.basename(tarball)), { recursive: true }),
|
||||
fs.remove(path.join(c.workspace(), 'bin', 'run.cmd')),
|
||||
]);
|
||||
+ // rename the original balena-cli ./bin/balena entry point for oclif compatibility
|
||||
+ await fs.move(path.join(c.workspace(), 'bin', 'balena'), path.join(c.workspace(), 'bin', 'run'));
|
||||
+ // The oclif installers are a production installation, while the source
|
||||
+ // `bin` folder may contain a `.fast-boot.json` file of a dev installation.
|
||||
+ // This has previously led to issues preventing the CLI from starting, so
|
||||
+ // delete `.fast-boot.json` (if any) from the destination folder.
|
||||
+ await fs.promises.rm(path.join(c.workspace(), 'bin', '.fast-boot.json'));
|
||||
};
|
||||
const updatePJSON = async () => {
|
||||
const pjsonPath = path.join(c.workspace(), 'package.json');
|
||||
@@ -49,35 +59,20 @@ async function build(c, options = {}) {
|
||||
await fs.writeJSON(pjsonPath, pjson, { spaces: 2 });
|
||||
};
|
||||
const addDependencies = async () => {
|
||||
- const yarnRoot = findYarnWorkspaceRoot(c.root) || c.root;
|
||||
- if (fs.existsSync(path.join(yarnRoot, 'yarn.lock'))) {
|
||||
- await fs.copy(path.join(yarnRoot, 'yarn.lock'), path.join(c.workspace(), 'yarn.lock'));
|
||||
- const yarnVersion = (await exec('yarn -v')).stdout.charAt(0);
|
||||
- if (yarnVersion === '1') {
|
||||
- await exec('yarn --no-progress --production --non-interactive', { cwd: c.workspace() });
|
||||
- }
|
||||
- else if (yarnVersion === '2') {
|
||||
- throw new Error('Yarn 2 is not supported yet. Try using Yarn 1, or Yarn 3');
|
||||
- }
|
||||
- else {
|
||||
- try {
|
||||
- await exec('yarn workspaces focus --production', { cwd: c.workspace() });
|
||||
- }
|
||||
- catch (error) {
|
||||
- if (error instanceof Error && error.message.includes('Command not found')) {
|
||||
- throw new Error('Missing workspace tools. Run `yarn plugin import workspace-tools`.');
|
||||
- }
|
||||
- throw error;
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- else {
|
||||
- const lockpath = fs.existsSync(path.join(c.root, 'package-lock.json')) ?
|
||||
- path.join(c.root, 'package-lock.json') :
|
||||
- path.join(c.root, 'npm-shrinkwrap.json');
|
||||
- await fs.copy(lockpath, path.join(c.workspace(), path.basename(lockpath)));
|
||||
- await exec('npm install --production', { cwd: c.workspace() });
|
||||
+ const ws = c.workspace();
|
||||
+ exec(`cd ${ws}`);
|
||||
+ console.error(`[debug] oclif copying node_modules to "${ws}"`)
|
||||
+ const source = path.join(c.root, 'node_modules');
|
||||
+ if (process.platform === 'win32') {
|
||||
+ await exec(`xcopy "${source}" "${ws}\\node_modules" /S /E /B /I /K /Q /Y`);
|
||||
+ } else {
|
||||
+ // use the shell's `cp` on macOS in order to preserve extended
|
||||
+ // file attributes containing `codesign` digital signatures
|
||||
+ await exec(`cp -pR "${source}" "${ws}"`);
|
||||
}
|
||||
+ console.error(`[debug] oclif running "npm prune --production" in "${ws}"`);
|
||||
+ await exec('npm prune --production', { cwd: c.workspace() });
|
||||
+ console.error(`[debug] oclif done`);
|
||||
};
|
||||
const pretarball = async () => {
|
||||
const pjson = await fs.readJSON(path.join(c.workspace(), 'package.json'));
|
||||
@@ -115,7 +110,8 @@ async function build(c, options = {}) {
|
||||
output: path.join(workspace, 'bin', 'node'),
|
||||
platform: target.platform,
|
||||
arch: target.arch,
|
||||
- tmp: path.join(config.root, 'tmp'),
|
||||
+ tmp,
|
||||
+ projectRootPath: c.root
|
||||
});
|
||||
if (options.pack === false)
|
||||
return;
|
||||
@@ -158,6 +154,7 @@ async function build(c, options = {}) {
|
||||
await fs.writeJSON(manifestFilepath, manifest, { spaces: 2 });
|
||||
};
|
||||
(0, log_1.log)(`gathering workspace for ${config.bin} to ${c.workspace()}`);
|
||||
+ console.error(`[debug] ${options.tarball}`);
|
||||
await extractCLI(options.tarball ? options.tarball : await packCLI());
|
||||
await updatePJSON();
|
||||
await addDependencies();
|
||||
diff --git a/node_modules/oclif/lib/tarballs/config.js b/node_modules/oclif/lib/tarballs/config.js
|
||||
index 216759d..f7bfbfe 100644
|
||||
--- a/node_modules/oclif/lib/tarballs/config.js
|
||||
+++ b/node_modules/oclif/lib/tarballs/config.js
|
||||
@@ -25,7 +25,10 @@ async function gitSha(cwd, options = {}) {
|
||||
}
|
||||
exports.gitSha = gitSha;
|
||||
async function Tmp(config) {
|
||||
- const tmp = path.join(config.root, 'tmp');
|
||||
+ const tmp = process.env.BUILD_TMP
|
||||
+ ? path.join(process.env.BUILD_TMP, 'oclif')
|
||||
+ : path.join(config.root, 'tmp');
|
||||
+ console.error(`[debug] oclif tmp="${tmp}"`);
|
||||
await fs.promises.mkdir(tmp, { recursive: true });
|
||||
return tmp;
|
||||
}
|
||||
@@ -62,7 +65,7 @@ async function buildConfig(root, options = {}) {
|
||||
s3Config: updateConfig.s3,
|
||||
nodeVersion,
|
||||
workspace(target) {
|
||||
- const base = path.join(config.root, 'tmp');
|
||||
+ const base = tmp;
|
||||
if (target && target.platform)
|
||||
return path.join(base, [target.platform, target.arch].join('-'), (0, upload_util_1.templateShortKey)('baseDir', { bin: config.bin }));
|
||||
return path.join(base, (0, upload_util_1.templateShortKey)('baseDir', { bin: config.bin }));
|
||||
diff --git a/node_modules/oclif/lib/tarballs/node.js b/node_modules/oclif/lib/tarballs/node.js
|
||||
index 1a4e09b..2d0566f 100644
|
||||
--- a/node_modules/oclif/lib/tarballs/node.js
|
||||
+++ b/node_modules/oclif/lib/tarballs/node.js
|
||||
@@ -11,9 +11,10 @@ const node_util_1 = require("node:util");
|
||||
const got_1 = require("got");
|
||||
const pipeline = (0, node_util_1.promisify)(node_stream_1.pipeline);
|
||||
const exec = (0, node_util_1.promisify)(node_child_process_1.exec);
|
||||
+const { isMSYS2, msysExec, toMsysPath } = require("../util");
|
||||
async function checkFor7Zip() {
|
||||
try {
|
||||
- await exec('7z');
|
||||
+ await msysExec('7z', { stdio: [0, null, 2] });
|
||||
}
|
||||
catch (error) {
|
||||
if (error.code === 127)
|
||||
@@ -51,8 +52,10 @@ async function fetchNodeBinary({ nodeVersion, output, platform, arch, tmp }) {
|
||||
const basedir = path.dirname(tarball);
|
||||
await fs.promises.mkdir(basedir, { recursive: true });
|
||||
await pipeline(got_1.default.stream(url), fs.createWriteStream(tarball));
|
||||
- if (platform !== 'win32')
|
||||
- await exec(`grep "${path.basename(tarball)}" "${shasums}" | shasum -a 256 -c -`, { cwd: basedir });
|
||||
+ if (platform !== 'win32') {
|
||||
+ const shaCmd = isMSYS2 ? 'sha256sum -c -' : 'shasum -a 256 -c -';
|
||||
+ await msysExec(`grep ${path.basename(tarball)} ${toMsysPath(shasums)} | ${shaCmd}`, { cwd: basedir });
|
||||
+ }
|
||||
};
|
||||
const extract = async () => {
|
||||
(0, log_1.log)(`extracting ${nodeBase}`);
|
||||
@@ -60,7 +63,7 @@ async function fetchNodeBinary({ nodeVersion, output, platform, arch, tmp }) {
|
||||
await fs.promises.mkdir(nodeTmp, { recursive: true });
|
||||
await fs.promises.mkdir(path.dirname(cache), { recursive: true });
|
||||
if (platform === 'win32') {
|
||||
- await exec(`7z x -bd -y "${tarball}"`, { cwd: nodeTmp });
|
||||
+ await msysExec(`7z x -bd -y ${toMsysPath(tarball)} > /dev/null`, { cwd: nodeTmp });
|
||||
await fs.move(path.join(nodeTmp, nodeBase, 'node.exe'), path.join(cache, 'node.exe'));
|
||||
}
|
||||
else {
|
||||
diff --git a/node_modules/oclif/lib/upload-util.js b/node_modules/oclif/lib/upload-util.js
|
||||
index 6963e4d..430472d 100644
|
||||
--- a/node_modules/oclif/lib/upload-util.js
|
||||
+++ b/node_modules/oclif/lib/upload-util.js
|
||||
@@ -31,10 +31,10 @@ options = { root: '.' }) {
|
||||
const templates = {
|
||||
baseDir: '<%- bin %>',
|
||||
unversioned: '<%- bin %>-<%- platform %>-<%- arch %><%- ext %>',
|
||||
- versioned: '<%- bin %>-v<%- version %>-<%- sha %>-<%- platform %>-<%- arch %><%- ext %>',
|
||||
- manifest: '<%- bin %>-v<%- version %>-<%- sha %>-<%- platform %>-<%- arch %>-buildmanifest',
|
||||
- macos: '<%- bin %>-v<%- version %>-<%- sha %>-<%- arch %>.pkg',
|
||||
- win32: '<%- bin %>-v<%- version %>-<%- sha %>-<%- arch %>.exe',
|
||||
+ versioned: '<%- bin %>-v<%- version %>-<%- platform %>-<%- arch %><%- ext %>',
|
||||
+ manifest: '<%- bin %>-v<%- version %>-<%- platform %>-<%- arch %>-buildmanifest',
|
||||
+ macos: '<%- bin %>-v<%- version %>.pkg',
|
||||
+ win32: '<%- bin %>-v<%- version %>-<%- arch %>.exe',
|
||||
deb: '<%- bin %>_<%- versionShaRevision %>_<%- arch %>.deb',
|
||||
};
|
||||
return _.template(templates[type])(Object.assign({}, options));
|
||||
diff --git a/node_modules/oclif/lib/util.js b/node_modules/oclif/lib/util.js
|
||||
index 75bf3c6..c6a9c49 100644
|
||||
--- a/node_modules/oclif/lib/util.js
|
||||
+++ b/node_modules/oclif/lib/util.js
|
||||
@@ -74,6 +74,51 @@ const sortVersionsObjectByKeysDesc = (input) => {
|
||||
}
|
||||
return result;
|
||||
};
|
||||
+
|
||||
+// OSTYPE is 'msys' for MSYS 1.0 and for MSYS2, or 'cygwin' for Cygwin
|
||||
+// but note that OSTYPE is not "exported" by default, so run: export OSTYPE=$OSTYPE
|
||||
+// MSYSTEM is 'MINGW32' for MSYS 1.0, 'MSYS' for MSYS2, and undefined for Cygwin
|
||||
+const isCygwin = process.env.OSTYPE === 'cygwin';
|
||||
+const isMinGW = process.env.MSYSTEM && process.env.MSYSTEM.startsWith('MINGW');
|
||||
+const isMSYS2 = process.env.MSYSTEM && process.env.MSYSTEM.startsWith('MSYS');
|
||||
+const MSYSSHELLPATH = process.env.MSYSSHELLPATH ||
|
||||
+ (isMSYS2 ? 'C:\\msys64\\usr\\bin\\bash.exe' :
|
||||
+ (isMinGW ? 'C:\\MinGW\\msys\\1.0\\bin\\bash.exe' :
|
||||
+ (isCygwin ? 'C:\\cygwin64\\bin\\bash.exe' : '/bin/sh')));
|
||||
+
|
||||
+exports.isCygwin = isCygwin;
|
||||
+exports.isMinGW = isMinGW;
|
||||
+exports.isMSYS2 = isMSYS2;
|
||||
+console.error(`[debug] oclif MSYSSHELLPATH=${MSYSSHELLPATH} MSYSTEM=${process.env.MSYSTEM} OSTYPE=${process.env.OSTYPE} isMSYS2=${isMSYS2} isMingGW=${isMinGW} isCygwin=${isCygwin}`);
|
||||
+
|
||||
+const child_process_1 = require("child_process");
|
||||
+const node_util_1 = require("node:util");
|
||||
+const exec = (0, node_util_1.promisify)(child_process_1.exec);
|
||||
+
|
||||
+/* Convert a Windows path like 'C:\tmp' to a MSYS path like '/c/tmp' */
|
||||
+function toMsysPath(windowsPath) {
|
||||
+ // 'c:\myfolder' -> '/c/myfolder' or '/cygdrive/c/myfolder'
|
||||
+ let msysPath = windowsPath.replace(/\\/g, '/');
|
||||
+ if (isMSYS2 || isMinGW) {
|
||||
+ msysPath = msysPath.replace(/^([a-zA-Z]):/, '/$1');
|
||||
+ } else if (isCygwin) {
|
||||
+ msysPath = msysPath.replace(/^([a-zA-Z]):/, '/cygdrive/$1');
|
||||
+ }
|
||||
+ console.error(`[debug] oclif toMsysPath before="${windowsPath}" after="${msysPath}"`);
|
||||
+ return msysPath;
|
||||
+}
|
||||
+exports.toMsysPath = toMsysPath;
|
||||
+
|
||||
+async function msysExec(cmd, options = {}) {
|
||||
+ if (process.platform !== 'win32') {
|
||||
+ return exec(cmd, options);
|
||||
+ }
|
||||
+ const sh = MSYSSHELLPATH;
|
||||
+ const args = ['-c', cmd];
|
||||
+ console.error(`[debug] oclif msysExec sh="${sh}" args=${JSON.stringify(args)} options=${JSON.stringify(options)}`);
|
||||
+ return exec(`"${sh}" "${args.join('" "')}"`, options);
|
||||
+}
|
||||
+exports.msysExec = msysExec;
|
||||
exports.sortVersionsObjectByKeysDesc = sortVersionsObjectByKeysDesc;
|
||||
const homeRegexp = new RegExp(`\\B${os.homedir().replace('/', '\\/')}`, 'g');
|
||||
const curRegexp = new RegExp(`\\B${process.cwd()}`, 'g');
|
@ -1,15 +0,0 @@
|
||||
diff --git a/node_modules/opn/index.js b/node_modules/opn/index.js
|
||||
index 13dcb66..0f0c1df 100644
|
||||
--- a/node_modules/opn/index.js
|
||||
+++ b/node_modules/opn/index.js
|
||||
@@ -51,7 +51,9 @@ module.exports = function (target, opts) {
|
||||
if (opts.app) {
|
||||
cmd = opts.app;
|
||||
} else {
|
||||
- cmd = path.join(__dirname, 'xdg-open');
|
||||
+ cmd = process.pkg
|
||||
+ ? path.join(path.dirname(process.execPath), 'xdg-open-402')
|
||||
+ : path.join(__dirname, 'xdg-open');
|
||||
}
|
||||
|
||||
if (appArgs.length > 0) {
|
@ -76,16 +76,9 @@
|
||||
The file must be distributed with executable as %2.
|
||||
%1: node_modules/drivelist/scripts/win32.bat
|
||||
%2: path-to-executable/drivelist/win32.bat
|
||||
> Warning Cannot include file %1 into executable.
|
||||
The file must be distributed with executable as %2.
|
||||
%1: node_modules/opn/xdg-open
|
||||
%2: path-to-executable/xdg-open
|
||||
> Warning Cannot include file %1 into executable.
|
||||
The file must be distributed with executable as %2.
|
||||
%1: node_modules/opn/xdg-open
|
||||
%2: path-to-executable/xdg-open
|
||||
prebuild-install warn install No prebuilt binaries found (target=v18.5.0 runtime=node arch=x64 libc= platform=darwin)
|
||||
prebuild-install warn install No prebuilt binaries found (target=v18.5.0 runtime=node arch=x64 libc= platform=darwin)
|
||||
prebuild-install warn install No prebuilt binaries found (target=v18.5.0 runtime=node arch=x64 libc= platform=darwin)
|
||||
prebuild-install warn install No prebuilt binaries found (target=v18.5.0 runtime=node arch=x64 libc= platform=darwin)
|
||||
prebuild-install warn install No prebuilt binaries found (target=v18.5.0 runtime=node arch=x64 libc= platform=darwin)
|
||||
|
||||
|
@ -76,15 +76,8 @@
|
||||
The file must be distributed with executable as %2.
|
||||
%1: node_modules/drivelist/scripts/win32.bat
|
||||
%2: path-to-executable/drivelist/win32.bat
|
||||
> Warning Cannot include file %1 into executable.
|
||||
The file must be distributed with executable as %2.
|
||||
%1: node_modules/opn/xdg-open
|
||||
%2: path-to-executable/xdg-open
|
||||
> Warning Cannot include file %1 into executable.
|
||||
The file must be distributed with executable as %2.
|
||||
%1: node_modules/opn/xdg-open
|
||||
%2: path-to-executable/xdg-open
|
||||
prebuild-install warn install No prebuilt binaries found (target=v18.5.0 runtime=node arch=arm64 libc= platform=linux)
|
||||
prebuild-install warn install No prebuilt binaries found (target=v18.5.0 runtime=node arch=arm64 libc= platform=linux)
|
||||
prebuild-install warn install No prebuilt binaries found (target=v18.5.0 runtime=node arch=arm64 libc= platform=linux)
|
||||
prebuild-install warn install No prebuilt binaries found (target=v18.5.0 runtime=node arch=arm64 libc= platform=linux)
|
||||
|
||||
|
@ -76,15 +76,8 @@
|
||||
The file must be distributed with executable as %2.
|
||||
%1: node_modules/drivelist/scripts/win32.bat
|
||||
%2: path-to-executable/drivelist/win32.bat
|
||||
> Warning Cannot include file %1 into executable.
|
||||
The file must be distributed with executable as %2.
|
||||
%1: node_modules/opn/xdg-open
|
||||
%2: path-to-executable/xdg-open
|
||||
> Warning Cannot include file %1 into executable.
|
||||
The file must be distributed with executable as %2.
|
||||
%1: node_modules/opn/xdg-open
|
||||
%2: path-to-executable/xdg-open
|
||||
prebuild-install warn install No prebuilt binaries found (target=v18.5.0 runtime=node arch=x64 libc= platform=linux)
|
||||
prebuild-install warn install No prebuilt binaries found (target=v18.5.0 runtime=node arch=x64 libc= platform=linux)
|
||||
prebuild-install warn install No prebuilt binaries found (target=v18.5.0 runtime=node arch=x64 libc= platform=linux)
|
||||
prebuild-install warn install No prebuilt binaries found (target=v18.5.0 runtime=node arch=x64 libc= platform=linux)
|
||||
|
||||
|
@ -76,11 +76,3 @@
|
||||
The file must be distributed with executable as %2.
|
||||
%1: node_modules\drivelist\scripts\win32.bat
|
||||
%2: path-to-executable/drivelist/win32.bat
|
||||
> Warning Cannot include file %1 into executable.
|
||||
The file must be distributed with executable as %2.
|
||||
%1: node_modules\opn\xdg-open
|
||||
%2: path-to-executable/xdg-open
|
||||
> Warning Cannot include file %1 into executable.
|
||||
The file must be distributed with executable as %2.
|
||||
%1: node_modules\opn\xdg-open
|
||||
%2: path-to-executable/xdg-open
|
||||
|
Loading…
Reference in New Issue
Block a user