@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,92 @@
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("node:fs"));
41
+ const aws_1 = __importDefault(require("../../aws"));
42
+ const log_1 = require("../../log");
43
+ const Tarballs = __importStar(require("../../tarballs"));
44
+ const upload_util_1 = require("../../upload-util");
45
+ const util_1 = require("../../util");
46
+ class UploadMacos extends core_1.Command {
47
+ static description = 'Upload macos installers built with `pack macos`.';
48
+ static flags = {
49
+ 'dry-run': core_1.Flags.boolean({ description: 'Run the command without uploading to S3.' }),
50
+ root: core_1.Flags.string({ char: 'r', default: '.', description: 'Path to oclif CLI root.', required: true }),
51
+ sha: core_1.Flags.string({
52
+ description: '7-digit short git commit SHA (defaults to current checked out commit).',
53
+ required: false,
54
+ }),
55
+ targets: core_1.Flags.string({
56
+ char: 't',
57
+ description: 'Comma-separated targets to upload (e.g.: darwin-x64,darwin-arm64).',
58
+ }),
59
+ };
60
+ async run() {
61
+ const { flags } = await this.parse(UploadMacos);
62
+ const buildConfig = await Tarballs.buildConfig(flags.root, { sha: flags?.sha, targets: flags?.targets?.split(',') });
63
+ const { config, dist, s3Config } = buildConfig;
64
+ const S3Options = {
65
+ ACL: s3Config.acl || 'public-read',
66
+ Bucket: s3Config.bucket,
67
+ };
68
+ const cloudKeyBase = (0, upload_util_1.commitAWSDir)(config.version, buildConfig.gitSha, s3Config);
69
+ const upload = async (arch) => {
70
+ const templateKey = (0, upload_util_1.templateShortKey)('macos', {
71
+ arch,
72
+ bin: config.bin,
73
+ sha: buildConfig.gitSha,
74
+ version: config.version,
75
+ });
76
+ const cloudKey = `${cloudKeyBase}/${templateKey}`;
77
+ const localPkg = dist(`macos/${templateKey}`);
78
+ if (fs.existsSync(localPkg))
79
+ await aws_1.default.s3.uploadFile(localPkg, { ...S3Options, CacheControl: 'max-age=86400', Key: cloudKey }, {
80
+ dryRun: flags['dry-run'],
81
+ });
82
+ else
83
+ this.error('Cannot find macOS pkg', {
84
+ suggestions: ['Run "oclif pack macos" before uploading'],
85
+ });
86
+ };
87
+ const arches = (0, util_1.uniq)(buildConfig.targets.filter((t) => t.platform === 'darwin').map((t) => t.arch));
88
+ await Promise.all(arches.map((a) => upload(a)));
89
+ (0, log_1.log)(`done uploading macos pkgs for v${config.version}-${buildConfig.gitSha}`);
90
+ }
91
+ }
92
+ exports.default = UploadMacos;
@@ -0,0 +1,12 @@
1
+ import { Command, Interfaces } from '@oclif/core';
2
+ export default class UploadTarballs extends Command {
3
+ static description: string;
4
+ static flags: {
5
+ 'dry-run': Interfaces.BooleanFlag<boolean>;
6
+ root: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
7
+ sha: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
8
+ targets: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
9
+ xz: Interfaces.BooleanFlag<boolean>;
10
+ };
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,135 @@
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("node:fs"));
41
+ const aws_1 = __importDefault(require("../../aws"));
42
+ const log_1 = require("../../log");
43
+ const Tarballs = __importStar(require("../../tarballs"));
44
+ const upload_util_1 = require("../../upload-util");
45
+ class UploadTarballs extends core_1.Command {
46
+ static description = 'Upload an oclif CLI to S3.';
47
+ static flags = {
48
+ 'dry-run': core_1.Flags.boolean({ description: 'Run the command without uploading to S3.' }),
49
+ root: core_1.Flags.string({ char: 'r', default: '.', description: 'Path to oclif CLI root.', required: true }),
50
+ sha: core_1.Flags.string({
51
+ description: '7-digit short git commit SHA (defaults to current checked out commit).',
52
+ required: false,
53
+ }),
54
+ targets: core_1.Flags.string({ char: 't', description: 'Comma-separated targets to upload (e.g.: linux-arm,win32-x64).' }),
55
+ xz: core_1.Flags.boolean({ allowNo: true, description: 'Also upload xz.' }),
56
+ };
57
+ async run() {
58
+ const { flags } = await this.parse(UploadTarballs);
59
+ const buildConfig = await Tarballs.buildConfig(flags.root, {
60
+ sha: flags?.sha,
61
+ targets: flags?.targets?.split(','),
62
+ xz: flags.xz,
63
+ });
64
+ const { config, dist, s3Config, xz } = buildConfig;
65
+ // fail early if targets are not built
66
+ for (const target of buildConfig.targets) {
67
+ const tarball = dist((0, upload_util_1.templateShortKey)('versioned', {
68
+ bin: config.bin,
69
+ ext: '.tar.gz',
70
+ sha: buildConfig.gitSha,
71
+ version: config.version,
72
+ ...target,
73
+ }));
74
+ if (!fs.existsSync(tarball))
75
+ this.error(`Cannot find a tarball ${tarball} for ${target.platform}-${target.arch}`, {
76
+ suggestions: [`Run "oclif pack --target ${target.platform}-${target.arch}" before uploading`],
77
+ });
78
+ }
79
+ const S3Options = {
80
+ ACL: s3Config.acl || 'public-read',
81
+ Bucket: s3Config.bucket,
82
+ };
83
+ const uploadTarball = async (options) => {
84
+ const shortKeyInputs = {
85
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
86
+ arch: options?.arch,
87
+ bin: config.bin,
88
+ // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
89
+ platform: options?.platform,
90
+ sha: buildConfig.gitSha,
91
+ version: config.version,
92
+ };
93
+ const releaseTarballs = async (ext) => {
94
+ const localKey = (0, upload_util_1.templateShortKey)('versioned', { ...shortKeyInputs, ext });
95
+ const cloudKey = `${(0, upload_util_1.commitAWSDir)(config.version, buildConfig.gitSha, s3Config)}/${localKey}`;
96
+ await aws_1.default.s3.uploadFile(dist(localKey), {
97
+ ...S3Options,
98
+ CacheControl: 'max-age=604800',
99
+ ContentType: 'application/gzip',
100
+ Key: cloudKey,
101
+ }, {
102
+ dryRun: flags['dry-run'],
103
+ });
104
+ };
105
+ const maybeUploadManifest = async () => {
106
+ const manifest = (0, upload_util_1.templateShortKey)('manifest', shortKeyInputs);
107
+ const cloudKey = `${(0, upload_util_1.commitAWSDir)(config.version, buildConfig.gitSha, s3Config)}/${manifest}`;
108
+ const local = dist(manifest);
109
+ (0, log_1.log)(`checking for buildmanifest at ${local}`);
110
+ if (fs.existsSync(local)) {
111
+ (0, log_1.log)(`uploading buildmanifest ${manifest}`);
112
+ return aws_1.default.s3.uploadFile(dist(manifest), {
113
+ ...S3Options,
114
+ CacheControl: 'max-age=86400',
115
+ ContentType: 'application/json',
116
+ Key: cloudKey,
117
+ }, {
118
+ dryRun: flags['dry-run'],
119
+ });
120
+ }
121
+ core_1.ux.warn(`Cannot find buildmanifest ${local}. CLI will not be able to update itself.`);
122
+ };
123
+ await Promise.all([
124
+ releaseTarballs('.tar.gz'),
125
+ maybeUploadManifest(),
126
+ ...(xz ? [releaseTarballs('.tar.xz')] : []),
127
+ ]);
128
+ };
129
+ if (buildConfig.targets.length > 0)
130
+ (0, log_1.log)('uploading targets');
131
+ await Promise.all(buildConfig.targets.map((t) => uploadTarball(t)));
132
+ (0, log_1.log)(`done uploading tarballs & manifests for v${config.version}-${buildConfig.gitSha}`);
133
+ }
134
+ }
135
+ exports.default = UploadTarballs;
@@ -0,0 +1,11 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class UploadWin extends Command {
3
+ static description: string;
4
+ static flags: {
5
+ 'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
6
+ root: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
+ sha: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ targets: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ };
10
+ run(): Promise<void>;
11
+ }
@@ -0,0 +1,97 @@
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("node:fs"));
41
+ const aws_1 = __importDefault(require("../../aws"));
42
+ const log_1 = require("../../log");
43
+ const Tarballs = __importStar(require("../../tarballs"));
44
+ const upload_util_1 = require("../../upload-util");
45
+ class UploadWin extends core_1.Command {
46
+ static description = 'Upload windows installers built with `pack win`.';
47
+ static flags = {
48
+ 'dry-run': core_1.Flags.boolean({ description: 'Run the command without uploading to S3.' }),
49
+ root: core_1.Flags.string({ char: 'r', default: '.', description: 'Path to oclif CLI root.', required: true }),
50
+ sha: core_1.Flags.string({
51
+ description: '7-digit short git commit SHA (defaults to current checked out commit).',
52
+ required: false,
53
+ }),
54
+ targets: core_1.Flags.string({ description: 'Comma-separated targets to pack (e.g.: win32-x64,win32-x86,win32-arm64).' }),
55
+ };
56
+ async run() {
57
+ const { flags } = await this.parse(UploadWin);
58
+ const buildConfig = await Tarballs.buildConfig(flags.root, { sha: flags?.sha, targets: flags?.targets?.split(',') });
59
+ const { config, dist, s3Config } = buildConfig;
60
+ const S3Options = {
61
+ ACL: s3Config.acl || 'public-read',
62
+ Bucket: s3Config.bucket,
63
+ };
64
+ const archs = buildConfig.targets.filter((t) => t.platform === 'win32').map((t) => t.arch);
65
+ for (const arch of archs) {
66
+ const templateKey = (0, upload_util_1.templateShortKey)('win32', {
67
+ arch,
68
+ bin: config.bin,
69
+ sha: buildConfig.gitSha,
70
+ version: config.version,
71
+ });
72
+ const localKey = dist(`win32/${templateKey}`);
73
+ if (!fs.existsSync(localKey))
74
+ this.error(`Cannot find Windows exe for ${arch}`, {
75
+ suggestions: ['Run "oclif pack win" before uploading'],
76
+ });
77
+ }
78
+ const cloudKeyBase = (0, upload_util_1.commitAWSDir)(config.pjson.version, buildConfig.gitSha, s3Config);
79
+ const uploadWin = async (arch) => {
80
+ const templateKey = (0, upload_util_1.templateShortKey)('win32', {
81
+ arch,
82
+ bin: config.bin,
83
+ sha: buildConfig.gitSha,
84
+ version: config.version,
85
+ });
86
+ const localExe = dist(`win32/${templateKey}`);
87
+ const cloudKey = `${cloudKeyBase}/${templateKey}`;
88
+ if (fs.existsSync(localExe))
89
+ await aws_1.default.s3.uploadFile(localExe, { ...S3Options, CacheControl: 'max-age=86400', Key: cloudKey }, {
90
+ dryRun: flags['dry-run'],
91
+ });
92
+ };
93
+ await Promise.all([uploadWin('x64'), uploadWin('x86'), uploadWin('arm64')]);
94
+ (0, log_1.log)(`done uploading windows executables for v${config.version}-${buildConfig.gitSha}`);
95
+ }
96
+ }
97
+ exports.default = UploadWin;
@@ -0,0 +1,57 @@
1
+ import { Command, Interfaces } from '@oclif/core';
2
+ import { ExecOptions } from 'node:child_process';
3
+ export type FlaggablePrompt = {
4
+ message: string;
5
+ options?: readonly string[] | string[];
6
+ validate: (d: string) => boolean | string;
7
+ };
8
+ export type FlagsOfPrompts<T extends Record<string, FlaggablePrompt>> = Record<keyof T, Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>>;
9
+ export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof GeneratorCommand)['baseFlags'] & T['flags']>;
10
+ export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
11
+ export type GetFlagOrPromptOptions = {
12
+ /**
13
+ * The default value for the prompt if the `--yes` flag is provided.
14
+ */
15
+ defaultValue: string;
16
+ /**
17
+ * A function that returns a value if the user has not provided the value via the flag. This will rerun before
18
+ * the check for the `--yes` flag.
19
+ */
20
+ maybeOtherValue?: () => Promise<string | undefined>;
21
+ /**
22
+ * The name of the flaggable prompt. Corresponds to the key in `this.flags`.
23
+ */
24
+ name: string;
25
+ /**
26
+ * The type of prompt to display.
27
+ */
28
+ type: 'input' | 'select';
29
+ };
30
+ export declare function exec(command: string, opts?: ExecOptions & {
31
+ silent?: boolean;
32
+ }): Promise<{
33
+ stderr: string;
34
+ stdout: string;
35
+ }>;
36
+ export declare function readPJSON(location: string): Promise<(Interfaces.PJSON & {
37
+ scripts: Record<string, string>;
38
+ }) | undefined>;
39
+ export declare function makeFlags<T extends Record<string, FlaggablePrompt>>(flaggablePrompts: T): FlagsOfPrompts<T>;
40
+ export declare abstract class GeneratorCommand<T extends typeof Command> extends Command {
41
+ protected args: Args<T>;
42
+ protected flaggablePrompts: Record<string, FlaggablePrompt>;
43
+ protected flags: Flags<T>;
44
+ templatesDir: string;
45
+ /**
46
+ * Get a flag value or prompt the user for a value.
47
+ *
48
+ * Resolution order:
49
+ * - Flag value provided by the user
50
+ * - Value returned by `maybeOtherValue`
51
+ * - `defaultValue` if the `--yes` flag is provided
52
+ * - Prompt the user for a value
53
+ */
54
+ getFlagOrPrompt({ defaultValue, maybeOtherValue, name, type }: GetFlagOrPromptOptions): Promise<string>;
55
+ init(): Promise<void>;
56
+ template(source: string, destination: string, data?: Record<string, unknown>): Promise<void>;
57
+ }
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GeneratorCommand = void 0;
7
+ exports.exec = exec;
8
+ exports.readPJSON = readPJSON;
9
+ exports.makeFlags = makeFlags;
10
+ const core_1 = require("@oclif/core");
11
+ const ansis_1 = __importDefault(require("ansis"));
12
+ const ejs_1 = require("ejs");
13
+ const fs_extra_1 = require("fs-extra");
14
+ const node_child_process_1 = require("node:child_process");
15
+ const node_fs_1 = require("node:fs");
16
+ const promises_1 = require("node:fs/promises");
17
+ const node_path_1 = require("node:path");
18
+ const log_1 = require("./log");
19
+ const debug = log_1.debug.new(`generator`);
20
+ async function exec(command, opts) {
21
+ const silent = opts ? opts.silent : true;
22
+ return new Promise((resolve, reject) => {
23
+ if (!silent)
24
+ core_1.ux.stdout(ansis_1.default.dim(command));
25
+ const p = (0, node_child_process_1.exec)(command, opts ?? {}, (err, stdout, stderr) => {
26
+ if (err)
27
+ return reject(err);
28
+ resolve({ stderr, stdout });
29
+ });
30
+ if (!silent)
31
+ p.stdout?.pipe(process.stdout);
32
+ if (!silent)
33
+ p.stderr?.pipe(process.stderr);
34
+ });
35
+ }
36
+ async function readPJSON(location) {
37
+ try {
38
+ const packageJSON = await (0, promises_1.readFile)((0, node_path_1.join)(location, 'package.json'), 'utf8');
39
+ return JSON.parse(packageJSON);
40
+ }
41
+ catch { }
42
+ }
43
+ function validateInput(input, validate) {
44
+ const result = validate(input);
45
+ if (typeof result === 'string')
46
+ throw new Error(result);
47
+ return input;
48
+ }
49
+ function makeFlags(flaggablePrompts) {
50
+ return Object.fromEntries(Object.entries(flaggablePrompts).map(([key, value]) => [
51
+ key,
52
+ core_1.Flags.string({
53
+ description: `Supply answer for prompt: ${value.message}`,
54
+ options: value.options,
55
+ async parse(input) {
56
+ return validateInput(input, value.validate);
57
+ },
58
+ }),
59
+ ]));
60
+ }
61
+ class GeneratorCommand extends core_1.Command {
62
+ args;
63
+ flaggablePrompts;
64
+ flags;
65
+ templatesDir;
66
+ /**
67
+ * Get a flag value or prompt the user for a value.
68
+ *
69
+ * Resolution order:
70
+ * - Flag value provided by the user
71
+ * - Value returned by `maybeOtherValue`
72
+ * - `defaultValue` if the `--yes` flag is provided
73
+ * - Prompt the user for a value
74
+ */
75
+ async getFlagOrPrompt({ defaultValue, maybeOtherValue, name, type }) {
76
+ if (!this.flaggablePrompts)
77
+ throw new Error('No flaggable prompts defined');
78
+ if (!this.flaggablePrompts[name])
79
+ throw new Error(`No flaggable prompt defined for ${name}`);
80
+ const maybeFlag = () => {
81
+ if (this.flags[name]) {
82
+ this.log(`${ansis_1.default.green('?')} ${ansis_1.default.bold(this.flaggablePrompts[name].message)} ${ansis_1.default.cyan(this.flags[name])}`);
83
+ return this.flags[name];
84
+ }
85
+ };
86
+ const maybeDefault = () => {
87
+ if (this.flags.yes) {
88
+ this.log(`${ansis_1.default.green('?')} ${ansis_1.default.bold(this.flaggablePrompts[name].message)} ${ansis_1.default.cyan(defaultValue)}`);
89
+ return defaultValue;
90
+ }
91
+ };
92
+ const checkMaybeOtherValue = async () => {
93
+ if (!maybeOtherValue)
94
+ return;
95
+ const otherValue = await maybeOtherValue();
96
+ if (otherValue) {
97
+ this.log(`${ansis_1.default.green('?')} ${ansis_1.default.bold(this.flaggablePrompts[name].message)} ${ansis_1.default.cyan(otherValue)}`);
98
+ return otherValue;
99
+ }
100
+ };
101
+ switch (type) {
102
+ case 'input': {
103
+ return (maybeFlag() ??
104
+ (await checkMaybeOtherValue()) ??
105
+ maybeDefault() ??
106
+ // Dynamic import because @inquirer/input is ESM only. Once oclif is ESM, we can make this a normal import
107
+ // so that we can avoid importing on every single question.
108
+ (await import('@inquirer/input')).default({
109
+ default: defaultValue,
110
+ message: this.flaggablePrompts[name].message,
111
+ validate: this.flaggablePrompts[name].validate,
112
+ }));
113
+ }
114
+ case 'select': {
115
+ return (maybeFlag() ??
116
+ (await checkMaybeOtherValue()) ??
117
+ maybeDefault() ??
118
+ // Dynamic import because @inquirer/select is ESM only. Once oclif is ESM, we can make this a normal import
119
+ // so that we can avoid importing on every single question.
120
+ (await import('@inquirer/select')).default({
121
+ choices: (this.flaggablePrompts[name].options ?? []).map((o) => ({ name: o, value: o })),
122
+ default: defaultValue,
123
+ message: this.flaggablePrompts[name].message,
124
+ }));
125
+ }
126
+ default: {
127
+ throw new Error('Invalid type');
128
+ }
129
+ }
130
+ }
131
+ async init() {
132
+ await super.init();
133
+ const { args, flags } = await this.parse({
134
+ args: this.ctor.args,
135
+ baseFlags: super.ctor.baseFlags,
136
+ enableJsonFlag: this.ctor.enableJsonFlag,
137
+ flags: this.ctor.flags,
138
+ strict: this.ctor.strict,
139
+ });
140
+ this.flags = flags;
141
+ this.args = args;
142
+ // @ts-expect-error because we trust that child classes will set this - also, it's okay if they don't
143
+ this.flaggablePrompts = this.ctor.flaggablePrompts ?? {};
144
+ this.templatesDir = (0, node_path_1.join)(__dirname, '../templates');
145
+ debug(`Templates directory: ${this.templatesDir}`);
146
+ }
147
+ async template(source, destination, data) {
148
+ if (this.flags['dry-run']) {
149
+ debug('[DRY RUN] Rendering template %s to %s', source, destination);
150
+ }
151
+ else {
152
+ debug('Rendering template %s to %s', source, destination);
153
+ }
154
+ const rendered = await new Promise((resolve, reject) => {
155
+ (0, ejs_1.renderFile)(source, data ?? {}, (err, str) => {
156
+ if (err)
157
+ reject(err);
158
+ return resolve(str);
159
+ });
160
+ });
161
+ let verb = 'Creating';
162
+ if (rendered) {
163
+ const relativePath = (0, node_path_1.relative)(process.cwd(), destination);
164
+ if ((0, node_fs_1.existsSync)(destination)) {
165
+ const confirmation = this.flags.force ??
166
+ (await (await import('@inquirer/confirm')).default({
167
+ message: `Overwrite ${relativePath}?`,
168
+ }));
169
+ if (confirmation) {
170
+ verb = 'Overwriting';
171
+ }
172
+ else {
173
+ this.log(`${ansis_1.default.yellow('Skipping')} ${relativePath}`);
174
+ return;
175
+ }
176
+ }
177
+ this.log(`${ansis_1.default.yellow(verb)} ${relativePath}`);
178
+ if (!this.flags['dry-run']) {
179
+ await (0, fs_extra_1.outputFile)(destination, rendered);
180
+ }
181
+ }
182
+ }
183
+ }
184
+ exports.GeneratorCommand = GeneratorCommand;
@@ -0,0 +1,11 @@
1
+ import { Command, HelpBase } from '@oclif/core';
2
+ interface MaybeCompatibleHelp extends HelpBase {
3
+ command?: (command: Command.Cached) => string;
4
+ formatCommand?: (command: Command.Cached) => string;
5
+ }
6
+ export declare class HelpCompatibilityWrapper {
7
+ inner: MaybeCompatibleHelp;
8
+ constructor(inner: MaybeCompatibleHelp);
9
+ formatCommand(command: Command.Cached): string;
10
+ }
11
+ export {};
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HelpCompatibilityWrapper = void 0;
4
+ class IncompatibleHelpError extends Error {
5
+ message = 'Please implement `formatCommand` in your custom help class.\nSee https://oclif.io/docs/help_classes for more.';
6
+ }
7
+ class HelpCompatibilityWrapper {
8
+ inner;
9
+ constructor(inner) {
10
+ this.inner = inner;
11
+ }
12
+ formatCommand(command) {
13
+ if (this.inner.formatCommand) {
14
+ return this.inner.formatCommand(command);
15
+ }
16
+ if (this.inner.command) {
17
+ return command.description + '\n\n' + this.inner.command(command);
18
+ }
19
+ throw new IncompatibleHelpError();
20
+ }
21
+ }
22
+ exports.HelpCompatibilityWrapper = HelpCompatibilityWrapper;
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { run } from '@oclif/core';
package/lib/index.js ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var core_1 = require("@oclif/core");
4
+ Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
package/lib/log.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare const debug: any;
2
+ export declare function log(format: string, ...args: unknown[]): void;
package/lib/log.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.debug = void 0;
4
+ exports.log = log;
5
+ const core_1 = require("@oclif/core");
6
+ const node_util_1 = require("node:util");
7
+ const util_1 = require("./util");
8
+ exports.debug = require('debug')('oclif');
9
+ exports.debug.new = (name) => require('debug')(`oclif:${name}`);
10
+ function log(format, ...args) {
11
+ args = args.map((arg) => (0, util_1.prettifyPaths)(arg));
12
+ return exports.debug.enabled ? (0, exports.debug)(format, ...args) : core_1.ux.stdout(`oclif: ${(0, node_util_1.format)(format, ...args)}`);
13
+ }