oclif 4.22.80 → 4.22.82-qa.0

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.
@@ -73,6 +73,7 @@ class Promote extends core_1.Command {
73
73
  this.log(`Promoting v${flags.version} (${flags.sha}) to ${flags.channel} channel\n`);
74
74
  const buildConfig = await Tarballs.buildConfig(flags.root, { targets: flags?.targets?.split(',') });
75
75
  const { config, s3Config } = buildConfig;
76
+ const keys = (0, upload_util_1.s3Keys)(config, s3Config, { bin: config.bin, sha: flags.sha, version: flags.version });
76
77
  const indexDefaults = {
77
78
  maxAge: `max-age=${flags['max-age']}`,
78
79
  s3Config,
@@ -90,90 +91,67 @@ class Promote extends core_1.Command {
90
91
  const cloudChannelKey = (shortKey) => node_path_1.default.posix.join((0, upload_util_1.channelAWSDir)(flags.channel, s3Config), shortKey);
91
92
  // copy tarballs manifests
92
93
  const promoteManifest = async (target) => {
93
- const manifest = (0, upload_util_1.templateShortKey)('manifest', {
94
- arch: target.arch,
95
- bin: config.bin,
96
- platform: target.platform,
97
- sha: flags.sha,
98
- version: flags.version,
99
- });
100
- // strip version & sha so update/scripts can point to a static channel manifest
101
- const unversionedManifest = manifest.replace(`-v${flags.version}-${flags.sha}`, '');
94
+ const sourceKey = keys.cloudKey(keys.manifest({ arch: target.arch, platform: target.platform }));
95
+ const destKey = keys.channelManifest({ arch: target.arch, platform: target.platform }, flags.channel);
102
96
  await aws_1.default.s3.copyObject({
103
97
  ...awsDefaults,
104
- CopySource: cloudBucketCommitKey(manifest),
105
- Key: cloudChannelKey(unversionedManifest),
98
+ CopySource: node_path_1.default.posix.join(s3Config.bucket, sourceKey),
99
+ Key: destKey,
106
100
  }, {
107
101
  dryRun: flags['dry-run'],
108
102
  ignoreMissing: flags['ignore-missing'],
109
- namespace: unversionedManifest,
103
+ namespace: node_path_1.default.basename(destKey),
110
104
  });
111
105
  };
112
106
  const promoteGzTarballs = async (target) => {
113
- const versionedTarGzName = (0, upload_util_1.templateShortKey)('versioned', {
114
- arch: target.arch,
115
- bin: config.bin,
116
- ext: '.tar.gz',
117
- platform: target.platform,
118
- sha: flags.sha,
119
- version: flags.version,
120
- });
121
- const versionedTarGzKey = cloudBucketCommitKey(versionedTarGzName);
122
- // strip version & sha so update/scripts can point to a static channel tarball
123
- const unversionedTarGzName = versionedTarGzName.replace(`-v${flags.version}-${flags.sha}`, '');
124
- const unversionedTarGzKey = cloudChannelKey(unversionedTarGzName);
107
+ const targetOpts = { arch: target.arch, platform: target.platform };
108
+ const sourceKey = keys.cloudKey(keys.versioned('.tar.gz', targetOpts));
109
+ const destKey = keys.channelTarball('.tar.gz', targetOpts, flags.channel);
110
+ const copySource = node_path_1.default.posix.join(s3Config.bucket, sourceKey);
125
111
  await Promise.all([
126
112
  aws_1.default.s3.copyObject({
127
113
  ...awsDefaults,
128
- CopySource: versionedTarGzKey,
129
- Key: unversionedTarGzKey,
114
+ CopySource: copySource,
115
+ Key: destKey,
130
116
  }, {
131
117
  dryRun: flags['dry-run'],
132
118
  ignoreMissing: flags['ignore-missing'],
133
- namespace: unversionedTarGzName,
119
+ namespace: keys.indexFilename('.tar.gz', targetOpts, flags.channel),
134
120
  }),
135
121
  ...(flags.indexes
136
122
  ? [
137
123
  (0, version_indexes_1.appendToIndex)({
138
124
  ...indexDefaults,
139
125
  dryRun: flags['dry-run'],
140
- filename: unversionedTarGzName,
141
- originalUrl: versionedTarGzKey,
126
+ filename: keys.indexFilename('.tar.gz', targetOpts, flags.channel),
127
+ originalUrl: copySource,
142
128
  }),
143
129
  ]
144
130
  : []),
145
131
  ]);
146
132
  };
147
133
  const promoteXzTarballs = async (target) => {
148
- const versionedTarXzName = (0, upload_util_1.templateShortKey)('versioned', {
149
- arch: target.arch,
150
- bin: config.bin,
151
- ext: '.tar.xz',
152
- platform: target.platform,
153
- sha: flags.sha,
154
- version: flags.version,
155
- });
156
- const versionedTarXzKey = cloudBucketCommitKey(versionedTarXzName);
157
- // strip version & sha so update/scripts can point to a static channel tarball
158
- const unversionedTarXzName = versionedTarXzName.replace(`-v${flags.version}-${flags.sha}`, '');
159
- const unversionedTarXzKey = cloudChannelKey(unversionedTarXzName);
134
+ const targetOpts = { arch: target.arch, platform: target.platform };
135
+ const sourceKey = keys.cloudKey(keys.versioned('.tar.xz', targetOpts));
136
+ const destKey = keys.channelTarball('.tar.xz', targetOpts, flags.channel);
137
+ const copySource = node_path_1.default.posix.join(s3Config.bucket, sourceKey);
160
138
  await Promise.all([
161
139
  aws_1.default.s3.copyObject({
162
140
  ...awsDefaults,
163
- CopySource: versionedTarXzKey,
164
- Key: unversionedTarXzKey,
141
+ CopySource: copySource,
142
+ Key: destKey,
165
143
  }, {
166
144
  dryRun: flags['dry-run'],
167
145
  ignoreMissing: flags['ignore-missing'],
168
- namespace: unversionedTarXzName,
146
+ namespace: keys.indexFilename('.tar.xz', targetOpts, flags.channel),
169
147
  }),
170
148
  ...(flags.indexes
171
149
  ? [
172
150
  (0, version_indexes_1.appendToIndex)({
173
151
  ...indexDefaults,
174
152
  dryRun: flags['dry-run'],
175
- filename: unversionedTarXzName,
176
- originalUrl: versionedTarXzKey,
153
+ filename: keys.indexFilename('.tar.xz', targetOpts, flags.channel),
154
+ originalUrl: copySource,
177
155
  }),
178
156
  ]
179
157
  : []),
@@ -62,15 +62,10 @@ class UploadTarballs extends core_1.Command {
62
62
  xz: flags.xz,
63
63
  });
64
64
  const { config, dist, s3Config, xz } = buildConfig;
65
+ const keys = (0, upload_util_1.s3Keys)(config, s3Config, { bin: config.bin, sha: buildConfig.gitSha, version: config.version });
65
66
  // fail early if targets are not built
66
67
  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
- }));
68
+ const tarball = dist(keys.versioned('.tar.gz', { arch: target.arch, platform: target.platform }));
74
69
  if (!fs.existsSync(tarball))
75
70
  this.error(`Cannot find a tarball ${tarball} for ${target.platform}-${target.arch}`, {
76
71
  suggestions: [`Run "oclif pack --target ${target.platform}-${target.arch}" before uploading`],
@@ -81,18 +76,15 @@ class UploadTarballs extends core_1.Command {
81
76
  Bucket: s3Config.bucket,
82
77
  };
83
78
  const uploadTarball = async (options) => {
84
- const shortKeyInputs = {
79
+ const target = {
85
80
  // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
86
81
  arch: options?.arch,
87
- bin: config.bin,
88
82
  // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
89
83
  platform: options?.platform,
90
- sha: buildConfig.gitSha,
91
- version: config.version,
92
84
  };
93
85
  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}`;
86
+ const localKey = keys.versioned(ext, target);
87
+ const cloudKey = keys.cloudKey(localKey);
96
88
  await aws_1.default.s3.uploadFile(dist(localKey), {
97
89
  ...S3Options,
98
90
  CacheControl: 'max-age=604800',
@@ -103,8 +95,8 @@ class UploadTarballs extends core_1.Command {
103
95
  });
104
96
  };
105
97
  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}`;
98
+ const manifest = keys.manifest(target);
99
+ const cloudKey = keys.cloudKey(manifest);
108
100
  const local = dist(manifest);
109
101
  (0, log_1.log)(`checking for buildmanifest at ${local}`);
110
102
  if (fs.existsSync(local)) {
@@ -195,8 +195,8 @@ const buildTarget = async (target, c, options) => {
195
195
  const { arch, platform } = target;
196
196
  const { bin, version } = c.config;
197
197
  const { gitSha: sha } = c;
198
- const templateShortKeyCommonOptions = { arch, bin, platform, sha, version };
199
- const [gzLocalKey, xzLocalKey] = ['.tar.gz', '.tar.xz'].map((ext) => (0, upload_util_1.templateShortKey)('versioned', { ...templateShortKeyCommonOptions, ext }));
198
+ const keys = (0, upload_util_1.s3Keys)(c.config, c.s3Config, { bin, sha, version });
199
+ const [gzLocalKey, xzLocalKey] = ['.tar.gz', '.tar.xz'].map((ext) => keys.versioned(ext, { arch, platform }));
200
200
  const base = node_path_1.default.basename(gzLocalKey);
201
201
  (0, log_1.log)(`building target ${base}`);
202
202
  (0, log_1.log)('copying workspace', c.workspace(), workspace);
@@ -225,8 +225,8 @@ const buildTarget = async (target, c, options) => {
225
225
  if (!c.updateConfig.s3?.host)
226
226
  return;
227
227
  const rollout = typeof c.updateConfig.autoupdate === 'object' && c.updateConfig.autoupdate.rollout;
228
- const gzCloudKey = `${(0, upload_util_1.commitAWSDir)(version, sha, c.updateConfig.s3)}/${gzLocalKey}`;
229
- const xzCloudKey = `${(0, upload_util_1.commitAWSDir)(version, sha, c.updateConfig.s3)}/${xzLocalKey}`;
228
+ const gzCloudKey = keys.cloudKey(gzLocalKey);
229
+ const xzCloudKey = keys.cloudKey(xzLocalKey);
230
230
  const [sha256gz, sha256xz] = await Promise.all([
231
231
  (0, util_1.hash)('sha256', c.dist(gzLocalKey)),
232
232
  ...(c.xz ? [(0, util_1.hash)('sha256', c.dist(xzLocalKey))] : []),
@@ -245,6 +245,7 @@ const buildTarget = async (target, c, options) => {
245
245
  version,
246
246
  xz: c.xz ? c.config.s3Url(xzCloudKey) : undefined,
247
247
  };
248
- const manifestFilepath = c.dist((0, upload_util_1.templateShortKey)('manifest', templateShortKeyCommonOptions));
248
+ const manifestFilepath = c.dist(keys.manifest({ arch, platform }));
249
+ await (0, promises_1.mkdir)(node_path_1.default.dirname(manifestFilepath), { recursive: true });
249
250
  await (0, fs_extra_1.writeJSON)(manifestFilepath, manifest, { spaces: 2 });
250
251
  };
@@ -11,6 +11,23 @@ type TemplateOptions = Interfaces.Config.s3Key.Options | {
11
11
  versionShaRevision?: string;
12
12
  };
13
13
  export declare function templateShortKey(type: 'deb' | 'macos' | 'win32' | keyof Interfaces.S3Templates, options?: TemplateOptions): string;
14
+ type TargetOptions = {
15
+ arch: Interfaces.ArchTypes;
16
+ platform: Interfaces.PlatformTypes;
17
+ };
18
+ export declare function s3Keys(config: Interfaces.Config, s3Config: TarballConfig['s3Config'], options: {
19
+ bin: string;
20
+ sha: string;
21
+ version: string;
22
+ }): {
23
+ channelManifest(target: TargetOptions, channel: string): string;
24
+ channelTarball(ext: ".tar.gz" | ".tar.xz", target: TargetOptions, channel: string): string;
25
+ cloudKey(localKey: string): string;
26
+ /** Returns the filename suitable for use in version index files. */
27
+ indexFilename(ext: ".tar.gz" | ".tar.xz", target: TargetOptions, channel: string): string;
28
+ manifest(target: TargetOptions): string;
29
+ versioned(ext: ".tar.gz" | ".tar.xz", target: TargetOptions): string;
30
+ };
14
31
  export type DebArch = 'amd64' | 'arm64' | 'armel' | 'i386';
15
32
  export declare function debArch(arch: Interfaces.ArchTypes): DebArch;
16
33
  export declare function debVersion(buildConfig: TarballConfig): string;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.commitAWSDir = commitAWSDir;
7
7
  exports.channelAWSDir = channelAWSDir;
8
8
  exports.templateShortKey = templateShortKey;
9
+ exports.s3Keys = s3Keys;
9
10
  exports.debArch = debArch;
10
11
  exports.debVersion = debVersion;
11
12
  const ejs_1 = require("ejs");
@@ -39,6 +40,43 @@ function templateShortKey(type, options) {
39
40
  };
40
41
  return (0, ejs_1.render)(templates[type], { ...options });
41
42
  }
43
+ function s3Keys(config, s3Config, options) {
44
+ const hasCustom = Boolean(config.pjson.oclif?.update?.s3?.templates);
45
+ return {
46
+ channelManifest(target, channel) {
47
+ if (hasCustom) {
48
+ return config.s3Key('manifest', { ...target, channel });
49
+ }
50
+ const manifest = templateShortKey('manifest', { ...options, ...target });
51
+ const unversionedManifest = manifest.replace(`-v${options.version}-${options.sha}`, '');
52
+ return `${channelAWSDir(channel, s3Config)}/${unversionedManifest}`;
53
+ },
54
+ channelTarball(ext, target, channel) {
55
+ return hasCustom
56
+ ? config.s3Key('unversioned', ext, { ...target, channel })
57
+ : `${channelAWSDir(channel, s3Config)}/${templateShortKey('unversioned', { ...options, ...target, ext })}`;
58
+ },
59
+ cloudKey(localKey) {
60
+ return hasCustom ? localKey : `${commitAWSDir(options.version, options.sha, s3Config)}/${localKey}`;
61
+ },
62
+ /** Returns the filename suitable for use in version index files. */
63
+ indexFilename(ext, target, channel) {
64
+ return hasCustom
65
+ ? config.s3Key('unversioned', ext, { ...target, channel })
66
+ : templateShortKey('unversioned', { ...options, ...target, ext });
67
+ },
68
+ manifest(target) {
69
+ return hasCustom
70
+ ? config.s3Key('manifest', target)
71
+ : templateShortKey('manifest', { ...options, ...target });
72
+ },
73
+ versioned(ext, target) {
74
+ return hasCustom
75
+ ? config.s3Key('versioned', ext, target)
76
+ : templateShortKey('versioned', { ...options, ...target, ext });
77
+ },
78
+ };
79
+ }
42
80
  function debArch(arch) {
43
81
  if (arch === 'x64')
44
82
  return 'amd64';
@@ -1195,5 +1195,5 @@
1195
1195
  ]
1196
1196
  }
1197
1197
  },
1198
- "version": "4.22.80"
1198
+ "version": "4.22.82-qa.0"
1199
1199
  }
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "oclif",
3
3
  "description": "oclif: create your own CLI",
4
- "version": "4.22.80",
4
+ "version": "4.22.82-qa.0",
5
5
  "author": "Salesforce",
6
6
  "bin": {
7
7
  "oclif": "bin/run.js"
8
8
  },
9
9
  "bugs": "https://github.com/oclif/oclif/issues",
10
10
  "dependencies": {
11
- "@aws-sdk/client-cloudfront": "^3.990.0",
11
+ "@aws-sdk/client-cloudfront": "^3.995.0",
12
12
  "@aws-sdk/client-s3": "^3.995.0",
13
13
  "@inquirer/confirm": "^3.1.22",
14
14
  "@inquirer/input": "^2.2.4",