@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.
Files changed (106) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -0
  3. package/bin/dev.cmd +3 -0
  4. package/bin/dev.js +7 -0
  5. package/bin/run.cmd +3 -0
  6. package/bin/run.js +7 -0
  7. package/changes.json +62 -0
  8. package/lib/aws.d.ts +22 -0
  9. package/lib/aws.js +146 -0
  10. package/lib/commands/generate/command.d.ts +12 -0
  11. package/lib/commands/generate/command.js +44 -0
  12. package/lib/commands/generate/hook.d.ts +12 -0
  13. package/lib/commands/generate/hook.js +87 -0
  14. package/lib/commands/generate.d.ts +67 -0
  15. package/lib/commands/generate.js +269 -0
  16. package/lib/commands/init.d.ts +39 -0
  17. package/lib/commands/init.js +165 -0
  18. package/lib/commands/lock.d.ts +4 -0
  19. package/lib/commands/lock.js +70 -0
  20. package/lib/commands/manifest.d.ts +13 -0
  21. package/lib/commands/manifest.js +156 -0
  22. package/lib/commands/pack/deb.d.ts +13 -0
  23. package/lib/commands/pack/deb.js +194 -0
  24. package/lib/commands/pack/macos.d.ts +14 -0
  25. package/lib/commands/pack/macos.js +273 -0
  26. package/lib/commands/pack/tarballs.d.ts +15 -0
  27. package/lib/commands/pack/tarballs.js +77 -0
  28. package/lib/commands/pack/win.d.ts +16 -0
  29. package/lib/commands/pack/win.js +398 -0
  30. package/lib/commands/promote.d.ts +20 -0
  31. package/lib/commands/promote.js +305 -0
  32. package/lib/commands/readme.d.ts +19 -0
  33. package/lib/commands/readme.js +143 -0
  34. package/lib/commands/upload/deb.d.ts +10 -0
  35. package/lib/commands/upload/deb.js +113 -0
  36. package/lib/commands/upload/macos.d.ts +11 -0
  37. package/lib/commands/upload/macos.js +92 -0
  38. package/lib/commands/upload/tarballs.d.ts +12 -0
  39. package/lib/commands/upload/tarballs.js +135 -0
  40. package/lib/commands/upload/win.d.ts +11 -0
  41. package/lib/commands/upload/win.js +97 -0
  42. package/lib/generator.d.ts +57 -0
  43. package/lib/generator.js +184 -0
  44. package/lib/help-compatibility.d.ts +11 -0
  45. package/lib/help-compatibility.js +22 -0
  46. package/lib/index.d.ts +1 -0
  47. package/lib/index.js +4 -0
  48. package/lib/log.d.ts +2 -0
  49. package/lib/log.js +13 -0
  50. package/lib/readme-generator.d.ts +38 -0
  51. package/lib/readme-generator.js +305 -0
  52. package/lib/tarballs/bin.d.ts +7 -0
  53. package/lib/tarballs/bin.js +126 -0
  54. package/lib/tarballs/build.d.ts +10 -0
  55. package/lib/tarballs/build.js +250 -0
  56. package/lib/tarballs/config.d.ts +45 -0
  57. package/lib/tarballs/config.js +132 -0
  58. package/lib/tarballs/index.d.ts +4 -0
  59. package/lib/tarballs/index.js +20 -0
  60. package/lib/tarballs/node.d.ts +10 -0
  61. package/lib/tarballs/node.js +78 -0
  62. package/lib/upload-util.d.ts +17 -0
  63. package/lib/upload-util.js +56 -0
  64. package/lib/util.d.ts +18 -0
  65. package/lib/util.js +160 -0
  66. package/lib/version-indexes.d.ts +9 -0
  67. package/lib/version-indexes.js +119 -0
  68. package/oclif.manifest.json +1199 -0
  69. package/package.json +217 -0
  70. package/templates/cli/commonjs/.mocharc.json.ejs +11 -0
  71. package/templates/cli/commonjs/.vscode/launch.json.ejs +20 -0
  72. package/templates/cli/commonjs/bin/dev.cmd.ejs +3 -0
  73. package/templates/cli/commonjs/bin/dev.js.ejs +7 -0
  74. package/templates/cli/commonjs/bin/run.cmd.ejs +3 -0
  75. package/templates/cli/commonjs/bin/run.js.ejs +7 -0
  76. package/templates/cli/commonjs/eslint.config.mjs.ejs +19 -0
  77. package/templates/cli/commonjs/tsconfig.json.ejs +11 -0
  78. package/templates/cli/esm/.mocharc.json.ejs +15 -0
  79. package/templates/cli/esm/.vscode/launch.json.ejs +22 -0
  80. package/templates/cli/esm/bin/dev.cmd.ejs +3 -0
  81. package/templates/cli/esm/bin/dev.js.ejs +5 -0
  82. package/templates/cli/esm/bin/run.cmd.ejs +3 -0
  83. package/templates/cli/esm/bin/run.js.ejs +5 -0
  84. package/templates/cli/esm/eslint.config.mjs.ejs +9 -0
  85. package/templates/cli/esm/tsconfig.json.ejs +15 -0
  86. package/templates/cli/shared/.github/workflows/onPushToMain.yml.ejs +56 -0
  87. package/templates/cli/shared/.github/workflows/onRelease.yml.ejs +21 -0
  88. package/templates/cli/shared/.github/workflows/test.yml.ejs +23 -0
  89. package/templates/cli/shared/.gitignore.ejs +27 -0
  90. package/templates/cli/shared/.prettierrc.json.ejs +1 -0
  91. package/templates/cli/shared/README.md.ejs +396 -0
  92. package/templates/cli/shared/package.json.ejs +73 -0
  93. package/templates/cli/shared/src/commands/hello/index.ts.ejs +22 -0
  94. package/templates/cli/shared/src/commands/hello/world.ts.ejs +16 -0
  95. package/templates/cli/shared/src/index.ts.ejs +1 -0
  96. package/templates/cli/shared/test/commands/hello/index.test.ts.ejs +9 -0
  97. package/templates/cli/shared/test/commands/hello/world.test.ts.ejs +9 -0
  98. package/templates/cli/shared/test/tsconfig.json.ejs +9 -0
  99. package/templates/src/command.ts.ejs +27 -0
  100. package/templates/src/hook.ts.ejs +7 -0
  101. package/templates/src/init/dev.cmd.ejs +12 -0
  102. package/templates/src/init/dev.js.ejs +17 -0
  103. package/templates/src/init/run.cmd.ejs +3 -0
  104. package/templates/src/init/run.js.ejs +17 -0
  105. package/templates/test/command.test.ts.ejs +14 -0
  106. package/templates/test/hook.test.ts.ejs +9 -0
@@ -0,0 +1,156 @@
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 os = __importStar(require("node:os"));
43
+ const node_path_1 = __importDefault(require("node:path"));
44
+ async function fileExists(filePath) {
45
+ try {
46
+ await (0, fs_extra_1.access)(filePath);
47
+ return true;
48
+ }
49
+ catch {
50
+ return false;
51
+ }
52
+ }
53
+ class Manifest extends core_1.Command {
54
+ static args = {
55
+ path: core_1.Args.string({ default: '.', description: 'Path to plugin.' }),
56
+ };
57
+ static description = 'Generates plugin manifest json (oclif.manifest.json).';
58
+ static flags = {
59
+ jit: core_1.Flags.boolean({
60
+ allowNo: true,
61
+ default: true,
62
+ summary: 'Append commands from JIT plugins in manifest.',
63
+ }),
64
+ };
65
+ async run() {
66
+ const { flags } = await this.parse(Manifest);
67
+ try {
68
+ (0, fs_extra_1.unlinkSync)('oclif.manifest.json');
69
+ }
70
+ catch { }
71
+ const { args } = await this.parse(Manifest);
72
+ const root = node_path_1.default.resolve(args.path);
73
+ const packageJson = (0, fs_extra_1.readJSONSync)(node_path_1.default.join(root, 'package.json'));
74
+ let jitPluginManifests = [];
75
+ if (flags.jit && packageJson.oclif?.jitPlugins) {
76
+ this.debug('jitPlugins: %s', packageJson.oclif.jitPlugins);
77
+ const tmpDir = os.tmpdir();
78
+ const promises = Object.entries(packageJson.oclif.jitPlugins).map(async ([jitPlugin, version]) => {
79
+ const pluginDir = jitPlugin.replace('/', '-').replace('@', '');
80
+ const fullPath = node_path_1.default.join(tmpDir, pluginDir);
81
+ if (await fileExists(fullPath))
82
+ await (0, fs_extra_1.remove)(fullPath);
83
+ await (0, fs_extra_1.mkdir)(fullPath, { recursive: true });
84
+ const tarball = await this.downloadTarball(jitPlugin, version, fullPath);
85
+ await this.executeCommand(`tar -xzf "${tarball}"`, { cwd: fullPath });
86
+ const manifest = (await (0, fs_extra_1.readJSON)(node_path_1.default.join(fullPath, 'package', 'oclif.manifest.json')));
87
+ for (const command of Object.values(manifest.commands)) {
88
+ command.pluginType = 'jit';
89
+ }
90
+ return manifest;
91
+ });
92
+ core_1.ux.action.start('Generating JIT plugin manifests');
93
+ jitPluginManifests = await Promise.all(promises);
94
+ core_1.ux.action.stop();
95
+ }
96
+ let plugin = new core_1.Plugin({
97
+ errorOnManifestCreate: true,
98
+ ignoreManifest: true,
99
+ respectNoCacheDefault: true,
100
+ root,
101
+ type: 'core',
102
+ });
103
+ if (!plugin)
104
+ throw new Error('plugin not found');
105
+ await plugin.load();
106
+ if (!plugin.valid) {
107
+ const { PluginLegacy } = await import('@oclif/plugin-legacy');
108
+ // @ts-expect-error for now because PluginLegacy doesn't use the same major of @oclif/core
109
+ plugin = new PluginLegacy(this.config, plugin);
110
+ await plugin.load();
111
+ }
112
+ if (!Array.isArray(plugin.pjson.files)) {
113
+ this.error('The package.json has to contain a "files" array', {
114
+ ref: 'https://docs.npmjs.com/cli/v10/configuring-npm/package-json#files',
115
+ suggestions: [
116
+ 'Add a "files" property in the package.json listing the paths to the files that should be included in the published package',
117
+ ],
118
+ });
119
+ }
120
+ const dotfile = plugin.pjson.files.find((f) => f.endsWith('.oclif.manifest.json'));
121
+ const file = node_path_1.default.join(plugin.root, `${dotfile ? '.' : ''}oclif.manifest.json`);
122
+ for (const manifest of jitPluginManifests) {
123
+ plugin.manifest.commands = { ...plugin.manifest.commands, ...manifest.commands };
124
+ }
125
+ (0, fs_extra_1.writeFileSync)(file, JSON.stringify(plugin.manifest, null, 2));
126
+ this.log(`wrote manifest to ${file}`);
127
+ return plugin.manifest;
128
+ }
129
+ async downloadTarball(plugin, version, tarballStoragePath) {
130
+ const { stderr } = await this.executeCommand(`npm pack ${plugin}@${version} --pack-destination "${tarballStoragePath}" --json`);
131
+ // You can `npm pack` with multiple modules to download multiple at a time. There will be at least 1 if the command
132
+ // succeeded.
133
+ const tarballs = JSON.parse(stderr);
134
+ if (!Array.isArray(tarballs) || tarballs.length !== 1) {
135
+ throw new Error(`Could not download tarballs for ${plugin}. Tarball download was not in the correct format.`);
136
+ }
137
+ const { filename } = tarballs[0];
138
+ return node_path_1.default.join(tarballStoragePath, filename);
139
+ }
140
+ async executeCommand(command, options) {
141
+ return new Promise((resolve) => {
142
+ (0, node_child_process_1.exec)(command, options, (error, stderr, stdout) => {
143
+ if (error)
144
+ this.error(error);
145
+ const debugString = options?.cwd
146
+ ? `executing command: ${command} in ${options.cwd}`
147
+ : `executing command: ${command}`;
148
+ this.debug(debugString);
149
+ this.debug(stdout);
150
+ this.debug(stderr);
151
+ resolve({ stderr: stderr.toString(), stdout: stdout.toString() });
152
+ });
153
+ });
154
+ }
155
+ }
156
+ exports.default = Manifest;
@@ -0,0 +1,13 @@
1
+ import { Command, Interfaces } from '@oclif/core';
2
+ export default class PackDeb extends Command {
3
+ static description: string;
4
+ static flags: {
5
+ compression: Interfaces.OptionFlag<"xz" | "none" | "gzip" | "zstd" | undefined, Interfaces.CustomOptions>;
6
+ 'prune-lockfiles': Interfaces.BooleanFlag<boolean>;
7
+ root: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
8
+ sha: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
9
+ tarball: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
10
+ };
11
+ static summary: string;
12
+ run(): Promise<void>;
13
+ }
@@ -0,0 +1,194 @@
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 = __importStar(require("fs-extra"));
41
+ const node_child_process_1 = require("node:child_process");
42
+ const fsPromises = __importStar(require("node:fs/promises"));
43
+ const node_path_1 = __importDefault(require("node:path"));
44
+ const node_util_1 = require("node:util");
45
+ const semver_1 = require("semver");
46
+ const Tarballs = __importStar(require("../../tarballs"));
47
+ const upload_util_1 = require("../../upload-util");
48
+ const util_1 = require("../../util");
49
+ const exec = (0, node_util_1.promisify)(node_child_process_1.exec);
50
+ const scripts = {
51
+ /* eslint-disable no-useless-escape */
52
+ bin: (config) => `#!/usr/bin/env bash
53
+ set -e
54
+ echoerr() { echo "$@" 1>&2; }
55
+ get_script_dir () {
56
+ SOURCE="\${BASH_SOURCE[0]}"
57
+ # While \$SOURCE is a symlink, resolve it
58
+ while [ -h "\$SOURCE" ]; do
59
+ DIR="\$( cd -P "\$( dirname "\$SOURCE" )" && pwd )"
60
+ SOURCE="\$( readlink "\$SOURCE" )"
61
+ # If \$SOURCE was a relative symlink (so no "/" as prefix, need to resolve it relative to the symlink base directory
62
+ [[ \$SOURCE != /* ]] && SOURCE="\$DIR/\$SOURCE"
63
+ done
64
+ DIR="\$( cd -P "\$( dirname "\$SOURCE" )" && pwd )"
65
+ echo "\$DIR"
66
+ }
67
+ DIR=\$(get_script_dir)
68
+ export ${config.scopedEnvVarKey('UPDATE_INSTRUCTIONS')}="update with \\"sudo apt update && sudo apt install ${config.bin}\\""
69
+ \$DIR/node \$DIR/run "\$@"
70
+ `,
71
+ /* eslint-enable no-useless-escape */
72
+ control: (config, arch) => `Package: ${config.config.bin}
73
+ Version: ${(0, upload_util_1.debVersion)(config)}
74
+ Section: main
75
+ Priority: standard
76
+ Architecture: ${arch}
77
+ Maintainer: ${config.config.scopedEnvVar('AUTHOR') || config.config.pjson.author}
78
+ Description: ${config.config.pjson.description}
79
+ Aliases: ${config.config.binAliases?.join(', ')}
80
+ `,
81
+ ftparchive: (config) => `
82
+ APT::FTPArchive::Release {
83
+ Origin "${config.scopedEnvVar('AUTHOR') || config.pjson.author}";
84
+ Suite "stable";
85
+ `,
86
+ };
87
+ class PackDeb extends core_1.Command {
88
+ static description = 'Add a pretarball script to your package.json if you need to run any scripts before the tarball is created.';
89
+ static flags = {
90
+ compression: core_1.Flags.option({
91
+ options: ['gzip', 'none', 'xz', 'zstd'],
92
+ })({
93
+ char: 'z',
94
+ description: 'For more details see the `-Zcompress-type` section at https://man7.org/linux/man-pages/man1/dpkg-deb.1.html',
95
+ summary: 'Override the default compression used by dpkg-deb.',
96
+ }),
97
+ 'prune-lockfiles': core_1.Flags.boolean({ description: 'remove lockfiles in the tarball.', exclusive: ['tarball'] }),
98
+ root: core_1.Flags.string({ char: 'r', default: '.', description: 'Path to oclif CLI root.', required: true }),
99
+ sha: core_1.Flags.string({
100
+ description: '7-digit short git commit SHA (defaults to current checked out commit).',
101
+ required: false,
102
+ }),
103
+ tarball: core_1.Flags.string({
104
+ char: 't',
105
+ description: 'Optionally specify a path to a tarball already generated by NPM.',
106
+ exclusive: ['prune-lockfiles'],
107
+ required: false,
108
+ }),
109
+ };
110
+ static summary = 'Pack CLI into debian package.';
111
+ async run() {
112
+ if (process.platform !== 'linux')
113
+ throw new Error('debian packing must be run on linux');
114
+ const { flags } = await this.parse(PackDeb);
115
+ const buildConfig = await Tarballs.buildConfig(flags.root, { sha: flags?.sha });
116
+ const { config } = buildConfig;
117
+ await Tarballs.build(buildConfig, {
118
+ pack: false,
119
+ parallel: true,
120
+ platform: 'linux',
121
+ pruneLockfiles: flags['prune-lockfiles'],
122
+ tarball: flags.tarball,
123
+ });
124
+ const dist = buildConfig.dist('deb');
125
+ await fs.emptyDir(dist);
126
+ const build = async (arch) => {
127
+ this.log(`building debian / ${arch}`);
128
+ const target = { arch, platform: 'linux' };
129
+ const versionedDebBase = (0, upload_util_1.templateShortKey)('deb', {
130
+ arch: (0, upload_util_1.debArch)(arch),
131
+ bin: config.bin,
132
+ versionShaRevision: (0, upload_util_1.debVersion)(buildConfig),
133
+ });
134
+ const workspace = node_path_1.default.join(buildConfig.tmp, 'apt', versionedDebBase.replace('.deb', '.apt'));
135
+ await fs.remove(workspace);
136
+ await Promise.all([
137
+ fsPromises.mkdir(node_path_1.default.join(workspace, 'DEBIAN'), { recursive: true }),
138
+ fsPromises.mkdir(node_path_1.default.join(workspace, 'usr', 'bin'), { recursive: true }),
139
+ ]);
140
+ await fs.copy(buildConfig.workspace(target), node_path_1.default.join(workspace, 'usr', 'lib', config.dirname));
141
+ await Promise.all([
142
+ // usr/lib/oclif/bin/oclif (the executable)
143
+ fsPromises.writeFile(node_path_1.default.join(workspace, 'usr', 'lib', config.dirname, 'bin', config.bin), scripts.bin(config), { mode: 0o755 }),
144
+ fsPromises.writeFile(node_path_1.default.join(workspace, 'DEBIAN', 'control'), scripts.control(buildConfig, (0, upload_util_1.debArch)(arch))),
145
+ ]);
146
+ // symlink usr/bin/oclif points to usr/lib/oclif/bin/oclif
147
+ await exec(`ln -s "${node_path_1.default.join('..', 'lib', config.dirname, 'bin', config.bin)}" "${config.bin}"`, {
148
+ cwd: node_path_1.default.join(workspace, 'usr', 'bin'),
149
+ });
150
+ config.binAliases?.map((alias) => exec(`ln -sf "${node_path_1.default.join('..', 'lib', config.dirname, 'bin', config.bin)}" "${alias}"`, {
151
+ cwd: node_path_1.default.join(workspace, 'usr', 'bin'),
152
+ }));
153
+ await exec(`sudo chown -R root "${workspace}"`);
154
+ await exec(`sudo chgrp -R root "${workspace}"`);
155
+ const dpkgDeb = flags.compression ? `dpkg-deb --build "-Z${flags.compression}"` : 'dpkg-deb --build';
156
+ await exec(`${dpkgDeb} "${workspace}" "${node_path_1.default.join(dist, versionedDebBase)}"`);
157
+ this.log(`finished building debian / ${arch}`);
158
+ };
159
+ const arches = (0, util_1.uniq)(buildConfig.targets
160
+ .filter((t) => t.platform === 'linux')
161
+ .filter((t) => {
162
+ // Skip 32-bit Arm for Node.js 24+
163
+ if (t.arch === 'arm' && (0, semver_1.gt)(buildConfig.nodeVersion, '24.0.0')) {
164
+ return false;
165
+ }
166
+ return true;
167
+ })
168
+ .map((t) => t.arch));
169
+ await Promise.all(arches.map((a) => build(a)));
170
+ await exec('apt-ftparchive packages . > Packages', { cwd: dist });
171
+ this.log('debian packages created');
172
+ await Promise.all([
173
+ exec('gzip -c Packages > Packages.gz', { cwd: dist }),
174
+ exec('bzip2 -k Packages', { cwd: dist }),
175
+ exec('xz -k Packages', { cwd: dist }),
176
+ packForFTP(buildConfig, config, dist),
177
+ ]);
178
+ this.log('debian packages archived');
179
+ const gpgKey = config.scopedEnvVar('DEB_KEY');
180
+ if (gpgKey) {
181
+ this.log('adding gpg signatures to Release');
182
+ await exec(`gpg --digest-algo SHA512 --clearsign -u ${gpgKey} -o InRelease Release`, { cwd: dist });
183
+ await exec(`gpg --digest-algo SHA512 -abs -u ${gpgKey} -o Release.gpg Release`, { cwd: dist });
184
+ }
185
+ this.log('debian packing complete');
186
+ }
187
+ }
188
+ exports.default = PackDeb;
189
+ async function packForFTP(buildConfig, config, dist) {
190
+ const ftparchive = node_path_1.default.join(buildConfig.tmp, 'apt', 'apt-ftparchive.conf');
191
+ await fsPromises.mkdir(node_path_1.default.basename(ftparchive), { recursive: true });
192
+ await fs.writeFile(ftparchive, scripts.ftparchive(config));
193
+ await exec(`apt-ftparchive -c "${ftparchive}" release . > Release`, { cwd: dist });
194
+ }
@@ -0,0 +1,14 @@
1
+ import { Command, Interfaces } from '@oclif/core';
2
+ export default class PackMacos extends Command {
3
+ static description: string;
4
+ static flags: {
5
+ 'additional-cli': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
6
+ 'prune-lockfiles': Interfaces.BooleanFlag<boolean>;
7
+ root: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
8
+ sha: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
9
+ tarball: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
10
+ targets: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
11
+ };
12
+ static summary: string;
13
+ run(): Promise<void>;
14
+ }
@@ -0,0 +1,273 @@
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 = __importStar(require("fs-extra"));
41
+ const node_child_process_1 = require("node:child_process");
42
+ const os = __importStar(require("node:os"));
43
+ const node_path_1 = __importDefault(require("node:path"));
44
+ const node_util_1 = require("node:util");
45
+ const Tarballs = __importStar(require("../../tarballs"));
46
+ const upload_util_1 = require("../../upload-util");
47
+ const util_1 = require("../../util");
48
+ const exec = (0, node_util_1.promisify)(node_child_process_1.exec);
49
+ const noBundleConfiguration = `<?xml version="1.0" encoding="UTF-8"?>
50
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
51
+ <plist version="1.0">
52
+ <array/>
53
+ </plist>
54
+ `;
55
+ const scripts = {
56
+ postinstall: (config, additionalCLI) => `#!/usr/bin/env bash
57
+ set -x
58
+ sudo mkdir -p /usr/local/bin
59
+ sudo ln -sf /usr/local/lib/${config.dirname}/bin/${config.bin} /usr/local/bin/${config.bin}
60
+ ${config.binAliases
61
+ ? config.binAliases
62
+ ?.map((alias) => `sudo ln -sf /usr/local/lib/${config.dirname}/bin/${config.bin} /usr/local/bin/${alias}`)
63
+ .join(os.EOL)
64
+ : ''}
65
+ ${additionalCLI
66
+ ? `sudo ln -sf /usr/local/lib/${config.dirname}/bin/${additionalCLI} /usr/local/bin/${additionalCLI}`
67
+ : ''}
68
+ `,
69
+ preinstall: (config, additionalCLI) => `#!/usr/bin/env bash
70
+ sudo rm -rf /usr/local/lib/${config.dirname}
71
+ sudo rm -rf /usr/local/${config.bin}
72
+ sudo rm -rf /usr/local/bin/${config.bin}
73
+ ${additionalCLI
74
+ ? `sudo rm -rf /usr/local/${additionalCLI}
75
+ sudo rm -rf /usr/local/bin/${additionalCLI}`
76
+ : ''}
77
+ ${config.binAliases ? config.binAliases.map((alias) => `sudo rm -rf /usr/local/bin/${alias}`).join(os.EOL) : ''}
78
+ `,
79
+ uninstall(config, additionalCLI) {
80
+ const packageIdentifier = config.pjson.oclif.macos.identifier;
81
+ return `#!/usr/bin/env bash
82
+
83
+ #Parameters
84
+ DATE=\`date +%Y-%m-%d\`
85
+ TIME=\`date +%H:%M:%S\`
86
+ LOG_PREFIX="[$DATE $TIME]"
87
+
88
+ #Functions
89
+ log_info() {
90
+ echo "\${LOG_PREFIX}[INFO]" $1
91
+ }
92
+
93
+ log_warn() {
94
+ echo "\${LOG_PREFIX}[WARN]" $1
95
+ }
96
+
97
+ log_error() {
98
+ echo "\${LOG_PREFIX}[ERROR]" $1
99
+ }
100
+
101
+ #Check running user
102
+ if (( $EUID != 0 )); then
103
+ echo "Please run as root."
104
+ exit
105
+ fi
106
+
107
+ echo "Welcome to Application Uninstaller"
108
+ echo "The following packages will be REMOVED:"
109
+ echo " ${config.dirname}"
110
+ while [ "$1" != "-y" ]; do
111
+ read -p "Do you wish to continue [Y/n]?" answer
112
+ [[ $answer == "y" || $answer == "Y" || $answer == "" ]] && break
113
+ [[ $answer == "n" || $answer == "N" ]] && exit 0
114
+ echo "Please answer with 'y' or 'n'"
115
+ done
116
+
117
+ echo "Application uninstalling process started"
118
+ # remove bin aliases link
119
+ ${config.binAliases
120
+ ? config.binAliases.map((alias) => `find "/usr/local/bin/" -name "${alias}" | xargs rm`).join(os.EOL)
121
+ : ''}
122
+ # remove link to shortcut file
123
+ find "/usr/local/bin/" -name "${config.bin}" | xargs rm
124
+ ${additionalCLI ? `find "/usr/local/bin/" -name "${additionalCLI}" | xargs rm` : ''}
125
+ if [ $? -eq 0 ]
126
+ then
127
+ echo "[1/3] [DONE] Successfully deleted shortcut links"
128
+ else
129
+ echo "[1/3] [ERROR] Could not delete shortcut links" >&2
130
+ fi
131
+
132
+ #forget from pkgutil
133
+ pkgutil --forget "${packageIdentifier}" > /dev/null 2>&1
134
+ if [ $? -eq 0 ]
135
+ then
136
+ echo "[2/3] [DONE] Successfully deleted application information"
137
+ else
138
+ echo "[2/3] [ERROR] Could not delete application information" >&2
139
+ fi
140
+
141
+ #remove application source distribution
142
+ [ -e "/usr/local/lib/${config.dirname}" ] && rm -rf "/usr/local/lib/${config.dirname}"
143
+
144
+ #remove application data directory
145
+ [ -e "${config.dataDir}" ] && rm -rf "${config.dataDir}"
146
+
147
+ #remove application cache directory
148
+ [ -e "${config.cacheDir}" ] && rm -rf "${config.cacheDir}"
149
+
150
+ #remove application config directory
151
+ [ -e "${config.configDir}" ] && rm -rf "${config.configDir}"
152
+
153
+ if [ $? -eq 0 ]
154
+ then
155
+ echo "[3/3] [DONE] Successfully deleted application"
156
+ else
157
+ echo "[3/3] [ERROR] Could not delete application" >&2
158
+ fi
159
+
160
+ echo "Application uninstall process finished"
161
+ exit 0
162
+ `;
163
+ },
164
+ };
165
+ class PackMacos extends core_1.Command {
166
+ static description = 'Add a pretarball script to your package.json if you need to run any scripts before the tarball is created.';
167
+ static flags = {
168
+ 'additional-cli': core_1.Flags.string({
169
+ description: `An Oclif CLI other than the one listed in config.bin that should be made available to the user
170
+ the CLI should already exist in a directory named after the CLI that is the root of the tarball produced by "oclif pack:tarballs"`,
171
+ hidden: true,
172
+ }),
173
+ 'prune-lockfiles': core_1.Flags.boolean({ description: 'remove lockfiles in the tarball.', exclusive: ['tarball'] }),
174
+ root: core_1.Flags.string({
175
+ char: 'r',
176
+ default: '.',
177
+ description: 'Path to oclif CLI root.',
178
+ required: true,
179
+ }),
180
+ sha: core_1.Flags.string({
181
+ description: '7-digit short git commit SHA (defaults to current checked out commit).',
182
+ required: false,
183
+ }),
184
+ tarball: core_1.Flags.string({
185
+ char: 't',
186
+ description: 'Optionally specify a path to a tarball already generated by NPM.',
187
+ exclusive: ['prune-lockfiles'],
188
+ required: false,
189
+ }),
190
+ targets: core_1.Flags.string({
191
+ description: 'Comma-separated targets to pack (e.g.: darwin-x64,darwin-arm64).',
192
+ }),
193
+ };
194
+ static summary = 'Pack CLI into macOS .pkg';
195
+ async run() {
196
+ if (process.platform !== 'darwin')
197
+ this.error('must be run from macos');
198
+ const { flags } = await this.parse(PackMacos);
199
+ const buildConfig = await Tarballs.buildConfig(flags.root, { sha: flags?.sha, targets: flags?.targets?.split(',') });
200
+ const { config } = buildConfig;
201
+ const c = config.pjson.oclif;
202
+ if (!c.macos)
203
+ this.error('package.json is missing an oclif.macos config');
204
+ if (!c.macos.identifier)
205
+ this.error('package.json must have oclif.macos.identifier set');
206
+ const macos = c.macos;
207
+ const packageIdentifier = macos.identifier;
208
+ await Tarballs.build(buildConfig, {
209
+ pack: false,
210
+ parallel: true,
211
+ platform: 'darwin',
212
+ pruneLockfiles: flags['prune-lockfiles'],
213
+ tarball: flags.tarball,
214
+ });
215
+ const scriptsDir = node_path_1.default.join(buildConfig.tmp, 'macos/scripts');
216
+ await fs.emptyDir(buildConfig.dist('macos'));
217
+ const noBundleConfigurationPath = node_path_1.default.join(buildConfig.tmp, 'macos', 'no-bundle.plist');
218
+ const build = async (arch) => {
219
+ const templateKey = (0, upload_util_1.templateShortKey)('macos', {
220
+ arch,
221
+ bin: config.bin,
222
+ sha: buildConfig.gitSha,
223
+ version: config.version,
224
+ });
225
+ const dist = buildConfig.dist(`macos/${templateKey}`);
226
+ const rootDir = buildConfig.workspace({ arch, platform: 'darwin' });
227
+ const writeNoBundleConfiguration = async () => {
228
+ await fs.mkdir(node_path_1.default.dirname(noBundleConfigurationPath), { recursive: true });
229
+ await fs.writeFile(noBundleConfigurationPath, noBundleConfiguration, { mode: 0o755 });
230
+ };
231
+ const writeScript = async (script) => {
232
+ const scriptLocation = script === 'uninstall' ? [rootDir, 'bin'] : [scriptsDir];
233
+ scriptLocation.push(script);
234
+ await fs.mkdir(node_path_1.default.dirname(node_path_1.default.join(...scriptLocation)), { recursive: true });
235
+ await fs.writeFile(node_path_1.default.join(...scriptLocation), scripts[script](config, flags['additional-cli']), {
236
+ mode: 0o755,
237
+ });
238
+ };
239
+ await Promise.all([
240
+ writeNoBundleConfiguration(),
241
+ writeScript('preinstall'),
242
+ writeScript('postinstall'),
243
+ writeScript('uninstall'),
244
+ ]);
245
+ const args = [
246
+ '--root',
247
+ rootDir,
248
+ '--component-plist',
249
+ noBundleConfigurationPath,
250
+ '--identifier',
251
+ packageIdentifier,
252
+ '--version',
253
+ config.version,
254
+ '--install-location',
255
+ `/usr/local/lib/${config.dirname}`,
256
+ '--scripts',
257
+ scriptsDir,
258
+ ];
259
+ if (macos.sign) {
260
+ args.push('--sign', macos.sign);
261
+ }
262
+ else
263
+ this.debug('Skipping macOS pkg signing');
264
+ if (process.env.OSX_KEYCHAIN)
265
+ args.push('--keychain', process.env.OSX_KEYCHAIN);
266
+ args.push(dist);
267
+ await exec(`pkgbuild ${args.join(' ')}`);
268
+ };
269
+ const arches = (0, util_1.uniq)(buildConfig.targets.filter((t) => t.platform === 'darwin').map((t) => t.arch));
270
+ await Promise.all(arches.map((a) => build(a)));
271
+ }
272
+ }
273
+ exports.default = PackMacos;
@@ -0,0 +1,15 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class PackTarballs extends Command {
3
+ static description: string;
4
+ static flags: {
5
+ parallel: import("@oclif/core/interfaces").BooleanFlag<boolean>;
6
+ 'prune-lockfiles': import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ root: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
+ sha: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ tarball: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ targets: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ xz: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ };
13
+ static summary: string;
14
+ run(): Promise<void>;
15
+ }