@depup/oclif 4.22.92-depup.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.
- package/LICENSE +21 -0
- package/README.md +44 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +7 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +7 -0
- package/changes.json +62 -0
- package/lib/aws.d.ts +22 -0
- package/lib/aws.js +146 -0
- package/lib/commands/generate/command.d.ts +12 -0
- package/lib/commands/generate/command.js +44 -0
- package/lib/commands/generate/hook.d.ts +12 -0
- package/lib/commands/generate/hook.js +87 -0
- package/lib/commands/generate.d.ts +67 -0
- package/lib/commands/generate.js +269 -0
- package/lib/commands/init.d.ts +39 -0
- package/lib/commands/init.js +165 -0
- package/lib/commands/lock.d.ts +4 -0
- package/lib/commands/lock.js +70 -0
- package/lib/commands/manifest.d.ts +13 -0
- package/lib/commands/manifest.js +156 -0
- package/lib/commands/pack/deb.d.ts +13 -0
- package/lib/commands/pack/deb.js +194 -0
- package/lib/commands/pack/macos.d.ts +14 -0
- package/lib/commands/pack/macos.js +273 -0
- package/lib/commands/pack/tarballs.d.ts +15 -0
- package/lib/commands/pack/tarballs.js +77 -0
- package/lib/commands/pack/win.d.ts +16 -0
- package/lib/commands/pack/win.js +398 -0
- package/lib/commands/promote.d.ts +20 -0
- package/lib/commands/promote.js +305 -0
- package/lib/commands/readme.d.ts +19 -0
- package/lib/commands/readme.js +143 -0
- package/lib/commands/upload/deb.d.ts +10 -0
- package/lib/commands/upload/deb.js +113 -0
- package/lib/commands/upload/macos.d.ts +11 -0
- package/lib/commands/upload/macos.js +92 -0
- package/lib/commands/upload/tarballs.d.ts +12 -0
- package/lib/commands/upload/tarballs.js +135 -0
- package/lib/commands/upload/win.d.ts +11 -0
- package/lib/commands/upload/win.js +97 -0
- package/lib/generator.d.ts +57 -0
- package/lib/generator.js +184 -0
- package/lib/help-compatibility.d.ts +11 -0
- package/lib/help-compatibility.js +22 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +4 -0
- package/lib/log.d.ts +2 -0
- package/lib/log.js +13 -0
- package/lib/readme-generator.d.ts +38 -0
- package/lib/readme-generator.js +305 -0
- package/lib/tarballs/bin.d.ts +7 -0
- package/lib/tarballs/bin.js +126 -0
- package/lib/tarballs/build.d.ts +10 -0
- package/lib/tarballs/build.js +250 -0
- package/lib/tarballs/config.d.ts +45 -0
- package/lib/tarballs/config.js +132 -0
- package/lib/tarballs/index.d.ts +4 -0
- package/lib/tarballs/index.js +20 -0
- package/lib/tarballs/node.d.ts +10 -0
- package/lib/tarballs/node.js +78 -0
- package/lib/upload-util.d.ts +17 -0
- package/lib/upload-util.js +56 -0
- package/lib/util.d.ts +18 -0
- package/lib/util.js +160 -0
- package/lib/version-indexes.d.ts +9 -0
- package/lib/version-indexes.js +119 -0
- package/oclif.manifest.json +1199 -0
- package/package.json +217 -0
- package/templates/cli/commonjs/.mocharc.json.ejs +11 -0
- package/templates/cli/commonjs/.vscode/launch.json.ejs +20 -0
- package/templates/cli/commonjs/bin/dev.cmd.ejs +3 -0
- package/templates/cli/commonjs/bin/dev.js.ejs +7 -0
- package/templates/cli/commonjs/bin/run.cmd.ejs +3 -0
- package/templates/cli/commonjs/bin/run.js.ejs +7 -0
- package/templates/cli/commonjs/eslint.config.mjs.ejs +19 -0
- package/templates/cli/commonjs/tsconfig.json.ejs +11 -0
- package/templates/cli/esm/.mocharc.json.ejs +15 -0
- package/templates/cli/esm/.vscode/launch.json.ejs +22 -0
- package/templates/cli/esm/bin/dev.cmd.ejs +3 -0
- package/templates/cli/esm/bin/dev.js.ejs +5 -0
- package/templates/cli/esm/bin/run.cmd.ejs +3 -0
- package/templates/cli/esm/bin/run.js.ejs +5 -0
- package/templates/cli/esm/eslint.config.mjs.ejs +9 -0
- package/templates/cli/esm/tsconfig.json.ejs +15 -0
- package/templates/cli/shared/.github/workflows/onPushToMain.yml.ejs +56 -0
- package/templates/cli/shared/.github/workflows/onRelease.yml.ejs +21 -0
- package/templates/cli/shared/.github/workflows/test.yml.ejs +23 -0
- package/templates/cli/shared/.gitignore.ejs +27 -0
- package/templates/cli/shared/.prettierrc.json.ejs +1 -0
- package/templates/cli/shared/README.md.ejs +396 -0
- package/templates/cli/shared/package.json.ejs +73 -0
- package/templates/cli/shared/src/commands/hello/index.ts.ejs +22 -0
- package/templates/cli/shared/src/commands/hello/world.ts.ejs +16 -0
- package/templates/cli/shared/src/index.ts.ejs +1 -0
- package/templates/cli/shared/test/commands/hello/index.test.ts.ejs +9 -0
- package/templates/cli/shared/test/commands/hello/world.test.ts.ejs +9 -0
- package/templates/cli/shared/test/tsconfig.json.ejs +9 -0
- package/templates/src/command.ts.ejs +27 -0
- package/templates/src/hook.ts.ejs +7 -0
- package/templates/src/init/dev.cmd.ejs +12 -0
- package/templates/src/init/dev.js.ejs +17 -0
- package/templates/src/init/run.cmd.ejs +3 -0
- package/templates/src/init/run.js.ejs +17 -0
- package/templates/test/command.test.ts.ejs +14 -0
- package/templates/test/hook.test.ts.ejs +9 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const core_1 = require("@oclif/core");
|
|
37
|
+
const Tarballs = __importStar(require("../../tarballs"));
|
|
38
|
+
class PackTarballs extends core_1.Command {
|
|
39
|
+
static description = `This can be used to create oclif CLIs that use the system node or that come preloaded with a node binary.
|
|
40
|
+
|
|
41
|
+
Add a pretarball script to your package.json if you need to run any scripts before the tarball is created.`;
|
|
42
|
+
static flags = {
|
|
43
|
+
parallel: core_1.Flags.boolean({ description: 'Build tarballs in parallel.' }),
|
|
44
|
+
'prune-lockfiles': core_1.Flags.boolean({ description: 'remove lockfiles in the tarball.' }),
|
|
45
|
+
root: core_1.Flags.string({ char: 'r', default: '.', description: 'Path to oclif CLI root.', required: true }),
|
|
46
|
+
sha: core_1.Flags.string({
|
|
47
|
+
description: '7-digit short git commit SHA (defaults to current checked out commit).',
|
|
48
|
+
required: false,
|
|
49
|
+
}),
|
|
50
|
+
tarball: core_1.Flags.string({
|
|
51
|
+
char: 'l',
|
|
52
|
+
description: 'Optionally specify a path to a tarball already generated by NPM.',
|
|
53
|
+
required: false,
|
|
54
|
+
}),
|
|
55
|
+
targets: core_1.Flags.string({ char: 't', description: 'Comma-separated targets to pack (e.g.: linux-arm,win32-x64).' }),
|
|
56
|
+
xz: core_1.Flags.boolean({ allowNo: true, description: 'Also build xz.' }),
|
|
57
|
+
};
|
|
58
|
+
static summary = 'Package oclif CLI into tarballs.';
|
|
59
|
+
async run() {
|
|
60
|
+
const { flags } = await this.parse(PackTarballs);
|
|
61
|
+
const buildConfig = await Tarballs.buildConfig(flags.root, {
|
|
62
|
+
sha: flags?.sha,
|
|
63
|
+
targets: flags?.targets?.split(','),
|
|
64
|
+
xz: flags.xz,
|
|
65
|
+
});
|
|
66
|
+
if (buildConfig.targets.length === 0) {
|
|
67
|
+
throw new Error('Please specify one or more valid targets.');
|
|
68
|
+
}
|
|
69
|
+
await Tarballs.build(buildConfig, {
|
|
70
|
+
parallel: flags.parallel,
|
|
71
|
+
...(process.platform === 'win32' ? { platform: 'win32' } : {}),
|
|
72
|
+
pruneLockfiles: flags['prune-lockfiles'],
|
|
73
|
+
tarball: flags.tarball,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.default = PackTarballs;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Command, Interfaces } from '@oclif/core';
|
|
2
|
+
export default class PackWin extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
'additional-cli': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
6
|
+
'defender-exclusion': Interfaces.OptionFlag<"hidden" | "checked" | "unchecked", Interfaces.CustomOptions>;
|
|
7
|
+
'prune-lockfiles': Interfaces.BooleanFlag<boolean>;
|
|
8
|
+
root: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
9
|
+
sha: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
10
|
+
tarball: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
11
|
+
targets: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
12
|
+
};
|
|
13
|
+
static summary: string;
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
private checkForNSIS;
|
|
16
|
+
}
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const core_1 = require("@oclif/core");
|
|
40
|
+
const fs_extra_1 = require("fs-extra");
|
|
41
|
+
const node_child_process_1 = require("node:child_process");
|
|
42
|
+
const node_fs_1 = require("node:fs");
|
|
43
|
+
const promises_1 = require("node:fs/promises");
|
|
44
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
45
|
+
const node_util_1 = require("node:util");
|
|
46
|
+
const Tarballs = __importStar(require("../../tarballs"));
|
|
47
|
+
const upload_util_1 = require("../../upload-util");
|
|
48
|
+
const exec = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
49
|
+
const scripts = {
|
|
50
|
+
/* eslint-disable no-useless-escape */
|
|
51
|
+
cmd: (config, additionalCLI, nodeOptions) => `@echo off
|
|
52
|
+
setlocal enableextensions
|
|
53
|
+
|
|
54
|
+
set ${additionalCLI ? `${additionalCLI.toUpperCase()}_BINPATH` : config.scopedEnvVarKey('BINPATH')}=%~dp0\\${additionalCLI ?? config.bin}.cmd
|
|
55
|
+
if exist "%LOCALAPPDATA%\\${config.dirname}\\client\\bin\\${additionalCLI ?? config.bin}.cmd" (
|
|
56
|
+
"%LOCALAPPDATA%\\${config.dirname}\\client\\bin\\${additionalCLI ?? config.bin}.cmd" %*
|
|
57
|
+
) else (
|
|
58
|
+
"%~dp0\\..\\client\\bin\\node.exe" ${`${nodeOptions?.join(' ')} `}"%~dp0\\..\\client\\${additionalCLI ? `${additionalCLI}\\bin\\run` : String.raw `bin\run`}" %*
|
|
59
|
+
)
|
|
60
|
+
`,
|
|
61
|
+
nsis: ({ arch, config, customization, defenderOptional, hideDefenderOption, }) => `!include MUI2.nsh
|
|
62
|
+
|
|
63
|
+
!define Version '${config.version.split('-')[0]}'
|
|
64
|
+
Name "${config.name}"
|
|
65
|
+
CRCCheck On
|
|
66
|
+
InstallDirRegKey HKCU "Software\\${config.name}" ""
|
|
67
|
+
|
|
68
|
+
!insertmacro MUI_PAGE_COMPONENTS
|
|
69
|
+
!insertmacro MUI_PAGE_DIRECTORY
|
|
70
|
+
!insertmacro MUI_PAGE_INSTFILES
|
|
71
|
+
|
|
72
|
+
!insertmacro MUI_UNPAGE_CONFIRM
|
|
73
|
+
!insertmacro MUI_UNPAGE_INSTFILES
|
|
74
|
+
|
|
75
|
+
!insertmacro MUI_LANGUAGE "English"
|
|
76
|
+
|
|
77
|
+
OutFile "installer.exe"
|
|
78
|
+
VIProductVersion "\${VERSION}.0"
|
|
79
|
+
VIAddVersionKey /LANG=\${LANG_ENGLISH} "ProductName" "${config.name}"
|
|
80
|
+
VIAddVersionKey /LANG=\${LANG_ENGLISH} "Comments" "${config.pjson.homepage}"
|
|
81
|
+
VIAddVersionKey /LANG=\${LANG_ENGLISH} "CompanyName" "${config.scopedEnvVar('AUTHOR') || config.pjson.author}"
|
|
82
|
+
VIAddVersionKey /LANG=\${LANG_ENGLISH} "LegalCopyright" "${new Date().getFullYear()}"
|
|
83
|
+
VIAddVersionKey /LANG=\${LANG_ENGLISH} "FileDescription" "${config.pjson.description}"
|
|
84
|
+
VIAddVersionKey /LANG=\${LANG_ENGLISH} "FileVersion" "\${VERSION}.0"
|
|
85
|
+
VIAddVersionKey /LANG=\${LANG_ENGLISH} "ProductVersion" "\${VERSION}.0"
|
|
86
|
+
|
|
87
|
+
InstallDir "\$PROGRAMFILES${arch === 'x64' ? '64' : ''}\\${config.dirname}"
|
|
88
|
+
|
|
89
|
+
${customization}
|
|
90
|
+
|
|
91
|
+
Section "${config.name} CLI \${VERSION}"
|
|
92
|
+
SetOutPath $INSTDIR
|
|
93
|
+
File /r bin
|
|
94
|
+
File /r client
|
|
95
|
+
|
|
96
|
+
; Use explicit System32/Sysnative path to cmd.exe for security
|
|
97
|
+
StrCpy $0 "$WINDIR\\System32\\cmd.exe" ; Try System32 first
|
|
98
|
+
IfFileExists "$0" path_is_safe
|
|
99
|
+
StrCpy $0 "$WINDIR\\Sysnative\\cmd.exe" ; Try Sysnative for WOW64
|
|
100
|
+
IfFileExists "$0" path_is_safe
|
|
101
|
+
MessageBox MB_OK|MB_ICONSTOP "Error: Could not find system cmd.exe. Installation cannot continue."
|
|
102
|
+
Abort
|
|
103
|
+
|
|
104
|
+
path_is_safe:
|
|
105
|
+
|
|
106
|
+
WriteRegStr HKCU "Software\\${config.dirname}" "" $INSTDIR
|
|
107
|
+
WriteUninstaller "$INSTDIR\\Uninstall.exe"
|
|
108
|
+
WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${config.dirname}" \\
|
|
109
|
+
"DisplayName" "${config.name}"
|
|
110
|
+
WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${config.dirname}" \\
|
|
111
|
+
"DisplayVersion" "\${VERSION}"
|
|
112
|
+
WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${config.dirname}" \\
|
|
113
|
+
"UninstallString" "$\\"$INSTDIR\\uninstall.exe$\\""
|
|
114
|
+
WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${config.dirname}" \\
|
|
115
|
+
"Publisher" "${config.scopedEnvVar('AUTHOR') || config.pjson.author}"
|
|
116
|
+
SectionEnd
|
|
117
|
+
|
|
118
|
+
Section "Set PATH to ${config.name}"
|
|
119
|
+
Push "$INSTDIR\\bin"
|
|
120
|
+
Call AddToPath
|
|
121
|
+
SectionEnd
|
|
122
|
+
|
|
123
|
+
Section ${defenderOptional ? '/o ' : ''}"${hideDefenderOption ? '-' : ''}Add %LOCALAPPDATA%\\${config.dirname} to Windows Defender exclusions (highly recommended for performance!)"
|
|
124
|
+
ExecWait '"$0" /C powershell -ExecutionPolicy Bypass -Command "$\\"& {Add-MpPreference -ExclusionPath $\\"$LOCALAPPDATA\\${config.dirname}$\\"}$\\"" -FFFeatureOff SW_HIDE'
|
|
125
|
+
SectionEnd
|
|
126
|
+
|
|
127
|
+
Section "Uninstall"
|
|
128
|
+
Delete "$INSTDIR\\Uninstall.exe"
|
|
129
|
+
RMDir /r "$INSTDIR"
|
|
130
|
+
RMDir /r "$LOCALAPPDATA\\${config.dirname}"
|
|
131
|
+
DeleteRegKey /ifempty HKCU "Software\\${config.dirname}"
|
|
132
|
+
DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${config.dirname}"
|
|
133
|
+
SectionEnd
|
|
134
|
+
|
|
135
|
+
!define Environ 'HKCU "Environment"'
|
|
136
|
+
Function AddToPath
|
|
137
|
+
Exch $0
|
|
138
|
+
Push $1
|
|
139
|
+
Push $2
|
|
140
|
+
Push $3
|
|
141
|
+
Push $4
|
|
142
|
+
|
|
143
|
+
; NSIS ReadRegStr returns empty string on string overflow
|
|
144
|
+
; Native calls are used here to check actual length of PATH
|
|
145
|
+
|
|
146
|
+
; $4 = RegOpenKey(HKEY_CURRENT_USER, "Environment", &$3)
|
|
147
|
+
System::Call "advapi32::RegOpenKey(i 0x80000001, t'Environment', *i.r3) i.r4"
|
|
148
|
+
IntCmp $4 0 0 done done
|
|
149
|
+
; $4 = RegQueryValueEx($3, "PATH", (DWORD*)0, (DWORD*)0, &$1, ($2=NSIS_MAX_STRLEN, &$2))
|
|
150
|
+
; RegCloseKey($3)
|
|
151
|
+
System::Call "advapi32::RegQueryValueEx(i $3, t'PATH', i 0, i 0, t.r1, *i \${NSIS_MAX_STRLEN} r2) i.r4"
|
|
152
|
+
System::Call "advapi32::RegCloseKey(i $3)"
|
|
153
|
+
|
|
154
|
+
IntCmp $4 234 0 +4 +4 ; $4 == ERROR_MORE_DATA
|
|
155
|
+
DetailPrint "AddToPath: original length $2 > \${NSIS_MAX_STRLEN}"
|
|
156
|
+
MessageBox MB_OK "PATH not updated, original length $2 > \${NSIS_MAX_STRLEN}"
|
|
157
|
+
Goto done
|
|
158
|
+
|
|
159
|
+
IntCmp $4 0 +5 ; $4 != NO_ERROR
|
|
160
|
+
IntCmp $4 2 +3 ; $4 != ERROR_FILE_NOT_FOUND
|
|
161
|
+
DetailPrint "AddToPath: unexpected error code $4"
|
|
162
|
+
Goto done
|
|
163
|
+
StrCpy $1 ""
|
|
164
|
+
|
|
165
|
+
; Check if already in PATH
|
|
166
|
+
Push "$1;"
|
|
167
|
+
Push "$0;"
|
|
168
|
+
Call StrStr
|
|
169
|
+
Pop $2
|
|
170
|
+
StrCmp $2 "" 0 done
|
|
171
|
+
Push "$1;"
|
|
172
|
+
Push "$0\\;"
|
|
173
|
+
Call StrStr
|
|
174
|
+
Pop $2
|
|
175
|
+
StrCmp $2 "" 0 done
|
|
176
|
+
|
|
177
|
+
; Prevent NSIS string overflow
|
|
178
|
+
StrLen $2 $0
|
|
179
|
+
StrLen $3 $1
|
|
180
|
+
IntOp $2 $2 + $3
|
|
181
|
+
IntOp $2 $2 + 2 ; $2 = strlen(dir) + strlen(PATH) + sizeof(";")
|
|
182
|
+
IntCmp $2 \${NSIS_MAX_STRLEN} +4 +4 0
|
|
183
|
+
DetailPrint "AddToPath: new length $2 > \${NSIS_MAX_STRLEN}"
|
|
184
|
+
MessageBox MB_OK "PATH not updated, new length $2 > \${NSIS_MAX_STRLEN}."
|
|
185
|
+
Goto done
|
|
186
|
+
|
|
187
|
+
; Append dir to PATH
|
|
188
|
+
DetailPrint "Add to PATH: $0"
|
|
189
|
+
StrCpy $2 $1 1 -1
|
|
190
|
+
StrCmp $2 ";" 0 +2
|
|
191
|
+
StrCpy $1 $1 -1 ; remove trailing ';'
|
|
192
|
+
StrCmp $1 "" +2 ; no leading ';'
|
|
193
|
+
StrCpy $0 "$1;$0"
|
|
194
|
+
WriteRegExpandStr \${Environ} "PATH" $0
|
|
195
|
+
SendMessage \${HWND_BROADCAST} \${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
|
|
196
|
+
|
|
197
|
+
done:
|
|
198
|
+
Pop $4
|
|
199
|
+
Pop $3
|
|
200
|
+
Pop $2
|
|
201
|
+
Pop $1
|
|
202
|
+
Pop $0
|
|
203
|
+
FunctionEnd
|
|
204
|
+
|
|
205
|
+
; StrStr - find substring in a string
|
|
206
|
+
;
|
|
207
|
+
; Usage:
|
|
208
|
+
; Push "this is some string"
|
|
209
|
+
; Push "some"
|
|
210
|
+
; Call StrStr
|
|
211
|
+
; Pop $0 ; "some string"
|
|
212
|
+
|
|
213
|
+
Function StrStr
|
|
214
|
+
Exch $R1 ; $R1=substring, stack=[old$R1,string,...]
|
|
215
|
+
Exch ; stack=[string,old$R1,...]
|
|
216
|
+
Exch $R2 ; $R2=string, stack=[old$R2,old$R1,...]
|
|
217
|
+
Push $R3
|
|
218
|
+
Push $R4
|
|
219
|
+
Push $R5
|
|
220
|
+
StrLen $R3 $R1
|
|
221
|
+
StrCpy $R4 0
|
|
222
|
+
; $R1=substring, $R2=string, $R3=strlen(substring)
|
|
223
|
+
; $R4=count, $R5=tmp
|
|
224
|
+
loop:
|
|
225
|
+
StrCpy $R5 $R2 $R3 $R4
|
|
226
|
+
StrCmp $R5 $R1 done
|
|
227
|
+
StrCmp $R5 "" done
|
|
228
|
+
IntOp $R4 $R4 + 1
|
|
229
|
+
Goto loop
|
|
230
|
+
done:
|
|
231
|
+
StrCpy $R1 $R2 "" $R4
|
|
232
|
+
Pop $R5
|
|
233
|
+
Pop $R4
|
|
234
|
+
Pop $R3
|
|
235
|
+
Pop $R2
|
|
236
|
+
Exch $R1 ; $R1=old$R1, stack=[result,...]
|
|
237
|
+
FunctionEnd
|
|
238
|
+
`,
|
|
239
|
+
sh: (config) => `#!/bin/sh
|
|
240
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
|
|
241
|
+
|
|
242
|
+
"$basedir/../client/bin/${config.bin}.cmd" "$@"
|
|
243
|
+
ret=$?
|
|
244
|
+
exit $ret
|
|
245
|
+
`,
|
|
246
|
+
/* eslint-enable no-useless-escape */
|
|
247
|
+
};
|
|
248
|
+
class PackWin extends core_1.Command {
|
|
249
|
+
static description = `You need to have 7zip, nsis (makensis), and grep installed on your machine in order to run this command.
|
|
250
|
+
|
|
251
|
+
This command will produce unsigned installers unless you supply WINDOWS_SIGNING_PASS (prefixed with the name of your executable, e.g. OCLIF_WINDOWS_SIGNING_PASS) in the environment and have set the windows.name and windows.keypath properties in your package.json's oclif property.
|
|
252
|
+
|
|
253
|
+
Add a pretarball script to your package.json if you need to run any scripts before the tarball is created.`;
|
|
254
|
+
static flags = {
|
|
255
|
+
'additional-cli': core_1.Flags.string({
|
|
256
|
+
description: `An Oclif CLI other than the one listed in config.bin that should be made available to the user
|
|
257
|
+
the CLI should already exist in a directory named after the CLI that is the root of the tarball produced by "oclif pack:tarballs".`,
|
|
258
|
+
hidden: true,
|
|
259
|
+
}),
|
|
260
|
+
'defender-exclusion': core_1.Flags.option({
|
|
261
|
+
options: ['checked', 'unchecked', 'hidden'],
|
|
262
|
+
})({
|
|
263
|
+
default: 'checked',
|
|
264
|
+
description: 'There is no way to set a hidden checkbox with "true" as a default...the user can always allow full security',
|
|
265
|
+
summary: `Set to "checked" or "unchecked" to set the default value for the checkbox. Set to "hidden" to hide the option (will let defender do its thing).`,
|
|
266
|
+
}),
|
|
267
|
+
'prune-lockfiles': core_1.Flags.boolean({ description: 'remove lockfiles in the tarball.', exclusive: ['tarball'] }),
|
|
268
|
+
root: core_1.Flags.string({
|
|
269
|
+
char: 'r',
|
|
270
|
+
default: '.',
|
|
271
|
+
description: 'Path to oclif CLI root.',
|
|
272
|
+
required: true,
|
|
273
|
+
}),
|
|
274
|
+
sha: core_1.Flags.string({
|
|
275
|
+
description: '7-digit short git commit SHA (defaults to current checked out commit).',
|
|
276
|
+
required: false,
|
|
277
|
+
}),
|
|
278
|
+
tarball: core_1.Flags.string({
|
|
279
|
+
char: 't',
|
|
280
|
+
description: 'Optionally specify a path to a tarball already generated by NPM.',
|
|
281
|
+
exclusive: ['prune-lockfiles'],
|
|
282
|
+
required: false,
|
|
283
|
+
}),
|
|
284
|
+
targets: core_1.Flags.string({
|
|
285
|
+
description: 'Comma-separated targets to pack (e.g.: win32-x64,win32-x86,win32-arm64).',
|
|
286
|
+
}),
|
|
287
|
+
};
|
|
288
|
+
static summary = 'Create windows installer from oclif CLI';
|
|
289
|
+
async run() {
|
|
290
|
+
await this.checkForNSIS();
|
|
291
|
+
const { flags } = await this.parse(PackWin);
|
|
292
|
+
const buildConfig = await Tarballs.buildConfig(flags.root, { sha: flags?.sha, targets: flags?.targets?.split(',') });
|
|
293
|
+
const { config } = buildConfig;
|
|
294
|
+
const nsisCustomization = config.nsisCustomization ? (0, node_fs_1.readFileSync)(config.nsisCustomization, 'utf8') : '';
|
|
295
|
+
const arches = buildConfig.targets.filter((t) => t.platform === 'win32').map((t) => t.arch);
|
|
296
|
+
await Tarballs.build(buildConfig, {
|
|
297
|
+
pack: false,
|
|
298
|
+
parallel: true,
|
|
299
|
+
platform: 'win32',
|
|
300
|
+
pruneLockfiles: flags['prune-lockfiles'],
|
|
301
|
+
tarball: flags.tarball,
|
|
302
|
+
});
|
|
303
|
+
await Promise.all(arches.map(async (arch) => {
|
|
304
|
+
const installerBase = node_path_1.default.join(buildConfig.tmp, `windows-${arch}-installer`);
|
|
305
|
+
await (0, promises_1.rm)(installerBase, { force: true, recursive: true });
|
|
306
|
+
await (0, promises_1.mkdir)(node_path_1.default.join(installerBase, 'bin'), { recursive: true });
|
|
307
|
+
await Promise.all([
|
|
308
|
+
(0, promises_1.writeFile)(node_path_1.default.join(installerBase, 'bin', `${config.bin}.cmd`), scripts.cmd(config, undefined, buildConfig.nodeOptions)),
|
|
309
|
+
(0, promises_1.writeFile)(node_path_1.default.join(installerBase, 'bin', `${config.bin}`), scripts.sh(config)),
|
|
310
|
+
(0, promises_1.writeFile)(node_path_1.default.join(installerBase, `${config.bin}.nsi`), scripts.nsis({
|
|
311
|
+
arch,
|
|
312
|
+
config,
|
|
313
|
+
customization: nsisCustomization,
|
|
314
|
+
// hiding it also unchecks it
|
|
315
|
+
defenderOptional: flags['defender-exclusion'] === 'hidden' || flags['defender-exclusion'] === 'unchecked',
|
|
316
|
+
hideDefenderOption: flags['defender-exclusion'] === 'hidden',
|
|
317
|
+
})),
|
|
318
|
+
...(config.binAliases
|
|
319
|
+
? config.binAliases.flatMap((alias) =>
|
|
320
|
+
// write duplicate files for windows aliases
|
|
321
|
+
// this avoids mklink which can require admin privileges which not everyone has
|
|
322
|
+
[
|
|
323
|
+
(0, promises_1.writeFile)(node_path_1.default.join(installerBase, 'bin', `${alias}.cmd`), scripts.cmd(config)),
|
|
324
|
+
(0, promises_1.writeFile)(node_path_1.default.join(installerBase, 'bin', `${alias}`), scripts.sh(config)),
|
|
325
|
+
])
|
|
326
|
+
: []),
|
|
327
|
+
...(flags['additional-cli']
|
|
328
|
+
? [
|
|
329
|
+
(0, promises_1.writeFile)(node_path_1.default.join(installerBase, 'bin', `${flags['additional-cli']}.cmd`), scripts.cmd(config, flags['additional-cli'])),
|
|
330
|
+
(0, promises_1.writeFile)(node_path_1.default.join(installerBase, 'bin', `${flags['additional-cli']}`), scripts.sh({ bin: flags['additional-cli'] })),
|
|
331
|
+
]
|
|
332
|
+
: []),
|
|
333
|
+
]);
|
|
334
|
+
await (0, fs_extra_1.move)(buildConfig.workspace({ arch, platform: 'win32' }), node_path_1.default.join(installerBase, 'client'));
|
|
335
|
+
await exec(`makensis "${installerBase}/${config.bin}.nsi" | grep -v "\\[compress\\]" | grep -v "^File: Descending to"`);
|
|
336
|
+
const templateKey = (0, upload_util_1.templateShortKey)('win32', {
|
|
337
|
+
arch,
|
|
338
|
+
bin: config.bin,
|
|
339
|
+
sha: buildConfig.gitSha,
|
|
340
|
+
version: config.version,
|
|
341
|
+
});
|
|
342
|
+
const o = buildConfig.dist(`win32/${templateKey}`);
|
|
343
|
+
await (0, fs_extra_1.move)(node_path_1.default.join(installerBase, 'installer.exe'), o);
|
|
344
|
+
const { windows } = config.pjson.oclif;
|
|
345
|
+
if (windows && windows.name && windows.keypath) {
|
|
346
|
+
await signWindows(o, arch, config, windows);
|
|
347
|
+
}
|
|
348
|
+
else
|
|
349
|
+
this.debug('Skipping windows exe signing');
|
|
350
|
+
this.log(`built ${o}`);
|
|
351
|
+
}));
|
|
352
|
+
}
|
|
353
|
+
async checkForNSIS() {
|
|
354
|
+
try {
|
|
355
|
+
await exec('makensis');
|
|
356
|
+
}
|
|
357
|
+
catch (error) {
|
|
358
|
+
const { code } = error;
|
|
359
|
+
if (code === 1)
|
|
360
|
+
return;
|
|
361
|
+
if (code === 127)
|
|
362
|
+
this.error('install makensis');
|
|
363
|
+
else
|
|
364
|
+
throw error;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
exports.default = PackWin;
|
|
369
|
+
async function signWindows(o, arch, config, windows) {
|
|
370
|
+
if (!windows) {
|
|
371
|
+
throw new Error('windows not set in oclif configuration');
|
|
372
|
+
}
|
|
373
|
+
const buildLocationUnsigned = o.replace(`${arch}.exe`, `${arch}-unsigned.exe`);
|
|
374
|
+
await (0, fs_extra_1.move)(o, buildLocationUnsigned);
|
|
375
|
+
const pass = config.scopedEnvVar('WINDOWS_SIGNING_PASS');
|
|
376
|
+
if (!pass) {
|
|
377
|
+
throw new Error(`${config.scopedEnvVarKey('WINDOWS_SIGNING_PASS')} not set in the environment`);
|
|
378
|
+
}
|
|
379
|
+
const args = [
|
|
380
|
+
'-pkcs12',
|
|
381
|
+
windows.keypath,
|
|
382
|
+
'-pass',
|
|
383
|
+
`"${pass}"`,
|
|
384
|
+
'-n',
|
|
385
|
+
`"${windows.name}"`,
|
|
386
|
+
'-i',
|
|
387
|
+
windows.homepage || config.pjson.homepage,
|
|
388
|
+
'-t',
|
|
389
|
+
'http://timestamp.digicert.com',
|
|
390
|
+
'-h',
|
|
391
|
+
'sha512',
|
|
392
|
+
'-in',
|
|
393
|
+
buildLocationUnsigned,
|
|
394
|
+
'-out',
|
|
395
|
+
o,
|
|
396
|
+
];
|
|
397
|
+
await exec(`osslsigncode sign ${args.join(' ')}`);
|
|
398
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Promote extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
channel: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
deb: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
'ignore-missing': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
indexes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
macos: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
'max-age': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
root: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
sha: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
targets: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
version: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
win: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
xz: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
};
|
|
19
|
+
run(): Promise<void>;
|
|
20
|
+
}
|