oclif 4.2.0 → 4.3.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/README.md CHANGED
@@ -232,6 +232,8 @@ USAGE
232
232
  FLAGS
233
233
  -r, --root=<value> (required) [default: .] path to oclif CLI root
234
234
  -t, --tarball=<value> optionally specify a path to a tarball already generated by NPM
235
+ -Z, --compression=<value> optionally override compression, see output of
236
+ 'dpkg-deb --help' in the -Z description for valid options.
235
237
 
236
238
  DESCRIPTION
237
239
  pack CLI into debian package
package/bin/dev.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ts-node
2
2
  // eslint-disable-next-line node/shebang, unicorn/prefer-top-level-await
3
- (async () => {
3
+ ;(async () => {
4
4
  const oclif = await import('@oclif/core')
5
5
  await oclif.execute({development: true, dir: __dirname})
6
6
  })()
package/bin/run.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // eslint-disable-next-line unicorn/prefer-top-level-await
4
- (async () => {
4
+ ;(async () => {
5
5
  const oclif = await import('@oclif/core')
6
6
  await oclif.execute({dir: __dirname})
7
7
  })()
package/lib/aws.d.ts CHANGED
@@ -1,16 +1,16 @@
1
- import * as CloudFront from 'aws-sdk/clients/cloudfront';
2
- import * as S3 from 'aws-sdk/clients/s3';
1
+ import { CreateInvalidationCommandOutput, CreateInvalidationRequest } from '@aws-sdk/client-cloudfront';
2
+ import { CopyObjectOutput, CopyObjectRequest, DeleteObjectsOutput, DeleteObjectsRequest, GetObjectOutput, GetObjectRequest, HeadObjectOutput, HeadObjectRequest, ListObjectsV2Output, ListObjectsV2Request, PutObjectOutput, PutObjectRequest } from '@aws-sdk/client-s3';
3
3
  declare const _default: {
4
4
  readonly cloudfront: {
5
- createCloudfrontInvalidation: (options: CloudFront.Types.CreateInvalidationRequest) => Promise<unknown>;
5
+ createCloudfrontInvalidation: (options: CreateInvalidationRequest) => Promise<CreateInvalidationCommandOutput>;
6
6
  };
7
7
  readonly s3: {
8
- copyObject: (options: S3.Types.CopyObjectRequest) => Promise<unknown>;
9
- deleteObjects: (options: S3.Types.DeleteObjectsRequest) => Promise<S3.DeleteObjectsOutput>;
10
- getObject: (options: S3.Types.GetObjectRequest) => Promise<S3.GetObjectOutput>;
11
- headObject: (options: S3.Types.HeadObjectRequest) => Promise<S3.HeadObjectOutput>;
12
- listObjects: (options: S3.Types.ListObjectsV2Request) => Promise<S3.ListObjectsV2Output>;
13
- uploadFile: (local: string, options: S3.Types.PutObjectRequest) => Promise<unknown>;
8
+ copyObject: (options: CopyObjectRequest) => Promise<CopyObjectOutput>;
9
+ deleteObjects: (options: DeleteObjectsRequest) => Promise<DeleteObjectsOutput>;
10
+ getObject: (options: GetObjectRequest) => Promise<GetObjectOutput>;
11
+ headObject: (options: HeadObjectRequest) => Promise<HeadObjectOutput>;
12
+ listObjects: (options: ListObjectsV2Request) => Promise<ListObjectsV2Output>;
13
+ uploadFile: (local: string, options: PutObjectRequest) => Promise<PutObjectOutput>;
14
14
  };
15
15
  };
16
16
  export default _default;
package/lib/aws.js CHANGED
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const client_cloudfront_1 = require("@aws-sdk/client-cloudfront");
4
+ const client_s3_1 = require("@aws-sdk/client-s3");
3
5
  const fs_extra_1 = require("fs-extra");
4
6
  const log_1 = require("./log");
5
7
  const util_1 = require("./util");
@@ -7,7 +9,8 @@ const debug = log_1.debug.new('aws');
7
9
  const cache = {};
8
10
  const aws = {
9
11
  get cloudfront() {
10
- cache.cloudfront = cache.cloudfront || new (require('aws-sdk/clients/cloudfront'))(this.creds);
12
+ cache.cloudfront =
13
+ cache.cloudfront || new (require('@aws-sdk/client-cloudfront').CloudFrontClient)({ credentials: this.creds });
11
14
  return cache.cloudfront;
12
15
  },
13
16
  get creds() {
@@ -26,17 +29,18 @@ const aws = {
26
29
  try {
27
30
  cache.s3 =
28
31
  cache.s3 ??
29
- new (require('aws-sdk/clients/s3'))({
30
- ...this.creds,
32
+ new (require('@aws-sdk/client-s3').S3Client)({
33
+ credentials: this.creds,
31
34
  endpoint: process.env.AWS_S3_ENDPOINT,
32
- s3ForcePathStyle: Boolean(process.env.AWS_S3_FORCE_PATH_STYLE),
35
+ forcePathStyle: Boolean(process.env.AWS_S3_FORCE_PATH_STYLE),
36
+ region: process.env.AWS_REGION ?? 'us-east-1',
33
37
  });
34
38
  return cache.s3;
35
39
  }
36
40
  catch (error) {
37
41
  const { code, message } = error;
38
42
  if (code === 'MODULE_NOT_FOUND')
39
- throw new Error(`${message}\naws-sdk is needed to run this command.\nInstall aws-sdk as a devDependency in your CLI. \`yarn add -D aws-sdk\``);
43
+ throw new Error(`${message}\n@aws-sdk/client-s3 is needed to run this command.\nInstall @aws-sdk/client-s3 as a devDependency in your CLI. \`yarn add -D @aws-sdk/client-s3\``);
40
44
  throw error;
41
45
  }
42
46
  },
@@ -45,13 +49,11 @@ exports.default = {
45
49
  get cloudfront() {
46
50
  return {
47
51
  createCloudfrontInvalidation: (options) => new Promise((resolve, reject) => {
48
- (0, log_1.log)('createCloudfrontInvalidation', options.DistributionId, options.InvalidationBatch.Paths.Items);
49
- aws.cloudfront.createInvalidation(options, (err) => {
50
- if (err)
51
- reject(err);
52
- else
53
- resolve(null);
54
- });
52
+ (0, log_1.log)('createCloudfrontInvalidation', options.DistributionId, options.InvalidationBatch?.Paths?.Items);
53
+ aws.cloudfront
54
+ ?.send(new client_cloudfront_1.CreateInvalidationCommand(options))
55
+ .then((data) => resolve(data))
56
+ .catch((error) => reject(error));
55
57
  }),
56
58
  };
57
59
  },
@@ -59,71 +61,47 @@ exports.default = {
59
61
  return {
60
62
  copyObject: (options) => new Promise((resolve, reject) => {
61
63
  (0, log_1.log)('s3:copyObject', `from s3://${options.CopySource}`, `to s3://${options.Bucket}/${options.Key}`);
62
- aws.s3.copyObject(options, (err, data) => {
63
- if (err)
64
- reject(err);
65
- else
66
- resolve(data);
67
- });
64
+ aws.s3
65
+ ?.send(new client_s3_1.CopyObjectCommand(options))
66
+ .then((data) => resolve(data))
67
+ .catch((error) => reject(error));
68
68
  }),
69
69
  deleteObjects: (options) => new Promise((resolve, reject) => {
70
70
  debug('deleteObjects', `s3://${options.Bucket}`);
71
- aws.s3.deleteObjects(options, (err, deletedObjects) => {
72
- if (err)
73
- reject(err);
74
- resolve(deletedObjects);
75
- });
71
+ aws.s3
72
+ ?.send(new client_s3_1.DeleteObjectsCommand(options))
73
+ .then((data) => resolve(data))
74
+ .catch((error) => reject(error));
76
75
  }),
77
76
  getObject: (options) => new Promise((resolve, reject) => {
78
77
  debug('getObject', `s3://${options.Bucket}/${options.Key}`);
79
- aws.s3.getObject(options, (err, data) => {
80
- if (err)
81
- reject(err);
82
- else
83
- resolve(data);
84
- });
78
+ aws.s3
79
+ ?.send(new client_s3_1.GetObjectCommand(options))
80
+ .then((data) => resolve(data))
81
+ .catch((error) => reject(error));
85
82
  }),
86
83
  headObject: (options) => new Promise((resolve, reject) => {
87
84
  debug('s3:headObject', `s3://${options.Bucket}/${options.Key}`);
88
- aws.s3.headObject(options, (err, data) => {
89
- if (err)
90
- reject(err);
91
- else
92
- resolve(data);
93
- });
85
+ aws.s3
86
+ ?.send(new client_s3_1.HeadObjectCommand(options))
87
+ .then((data) => resolve(data))
88
+ .catch((error) => reject(error));
94
89
  }),
95
90
  listObjects: (options) => new Promise((resolve, reject) => {
96
91
  debug('listObjects', `s3://${options.Bucket}/${options.Prefix}`);
97
- aws.s3.listObjectsV2(options, (err, objects) => {
98
- if (err)
99
- reject(err);
100
- resolve(objects);
101
- });
92
+ aws.s3
93
+ ?.send(new client_s3_1.ListObjectsV2Command(options))
94
+ .then((data) => resolve(data))
95
+ .catch((error) => reject(error));
102
96
  }),
103
97
  uploadFile: (local, options) => new Promise((resolve, reject) => {
104
98
  (0, log_1.log)('s3:uploadFile', (0, util_1.prettifyPaths)(local), `s3://${options.Bucket}/${options.Key}`);
105
99
  options.Body = (0, fs_extra_1.createReadStream)(local);
106
- aws.s3.upload(options, (err) => {
107
- if (err)
108
- reject(err);
109
- else
110
- resolve(null);
111
- });
100
+ aws.s3
101
+ ?.send(new client_s3_1.PutObjectCommand(options))
102
+ .then((data) => resolve(data))
103
+ .catch((error) => reject(error));
112
104
  }),
113
105
  };
114
106
  },
115
107
  };
116
- // export const getObject = (options: S3.Types.GetObjectRequest) => new Promise<S3.GetObjectOutput>((resolve, reject) => {
117
- // debug('getObject', `s3://${options.Bucket}/${options.Key}`)
118
- // aws.s3().getObject(options, (err, data) => {
119
- // if (err) reject(err)
120
- // else resolve(data)
121
- // })
122
- // })
123
- // export const listObjects = (options: S3.Types.ListObjectsV2Request) => new Promise<S3.ListObjectsV2Output>((resolve, reject) => {
124
- // debug('listObjects', `s3://${options.Bucket}/${options.Prefix}`)
125
- // s3().listObjectsV2(options, (err, objects) => {
126
- // if (err) reject(err)
127
- // else resolve(objects)
128
- // })
129
- // })
@@ -2,6 +2,7 @@ import { Command, Interfaces } from '@oclif/core';
2
2
  export default class PackDeb extends Command {
3
3
  static description: string;
4
4
  static flags: {
5
+ compression: Interfaces.OptionFlag<"xz" | "gzip" | "none" | "zstd" | undefined, Interfaces.CustomOptions>;
5
6
  root: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
6
7
  tarball: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
7
8
  };
@@ -48,12 +48,19 @@ APT::FTPArchive::Release {
48
48
  `,
49
49
  };
50
50
  class PackDeb extends core_1.Command {
51
- static description = 'pack CLI into debian package';
51
+ static description = 'Pack CLI into debian package.';
52
52
  static flags = {
53
- root: core_1.Flags.string({ char: 'r', default: '.', description: 'path to oclif CLI root', required: true }),
53
+ compression: core_1.Flags.option({
54
+ options: ['gzip', 'none', 'xz', 'zstd'],
55
+ })({
56
+ char: 'z',
57
+ description: 'For more details see the `-Zcompress-type` section at https://man7.org/linux/man-pages/man1/dpkg-deb.1.html',
58
+ summary: 'Override the default compression used by dpkg-deb.',
59
+ }),
60
+ root: core_1.Flags.string({ char: 'r', default: '.', description: 'Path to oclif CLI root.', required: true }),
54
61
  tarball: core_1.Flags.string({
55
62
  char: 't',
56
- description: 'optionally specify a path to a tarball already generated by NPM',
63
+ description: 'Optionally specify a path to a tarball already generated by NPM.',
57
64
  required: false,
58
65
  }),
59
66
  };
@@ -95,7 +102,8 @@ class PackDeb extends core_1.Command {
95
102
  }));
96
103
  await exec(`sudo chown -R root "${workspace}"`);
97
104
  await exec(`sudo chgrp -R root "${workspace}"`);
98
- await exec(`dpkg --build "${workspace}" "${path.join(dist, versionedDebBase)}"`);
105
+ const dpkgDeb = flags.compression ? `dpkg-deb --build "-Z${flags.compression}"` : 'dpkg-deb --build';
106
+ await exec(`${dpkgDeb} "${workspace}" "${path.join(dist, versionedDebBase)}"`);
99
107
  this.log(`finished building debian / ${arch}`);
100
108
  };
101
109
  const arches = (0, util_1.uniq)(buildConfig.targets.filter((t) => t.platform === 'linux').map((t) => t.arch));
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const client_s3_1 = require("@aws-sdk/client-s3");
3
4
  const core_1 = require("@oclif/core");
4
5
  const path = require("node:path");
5
6
  const aws_1 = require("../aws");
@@ -34,10 +35,10 @@ class Promote extends core_1.Command {
34
35
  if (!s3Config.bucket)
35
36
  this.error('Cannot determine S3 bucket for promotion');
36
37
  const awsDefaults = {
37
- ACL: s3Config.acl ?? 'public-read',
38
+ ACL: s3Config.acl ?? client_s3_1.ObjectCannedACL.public_read,
38
39
  Bucket: s3Config.bucket,
39
40
  CacheControl: indexDefaults.maxAge,
40
- MetadataDirective: 'REPLACE',
41
+ MetadataDirective: client_s3_1.MetadataDirective.REPLACE,
41
42
  };
42
43
  const cloudBucketCommitKey = (shortKey) => path.join(s3Config.bucket, (0, upload_util_1.commitAWSDir)(flags.version, flags.sha, s3Config), shortKey);
43
44
  const cloudChannelKey = (shortKey) => path.join((0, upload_util_1.channelAWSDir)(flags.channel, s3Config), shortKey);
@@ -1,5 +1,17 @@
1
+ import { ObjectCannedACL } from '@aws-sdk/client-s3';
1
2
  import { Interfaces } from '@oclif/core';
2
3
  export declare const TARGETS: string[];
4
+ export type S3Config = BuildConfig['updateConfig']['s3'] & {
5
+ folder?: string;
6
+ indexVersionLimit?: number;
7
+ } & {
8
+ acl?: ObjectCannedACL;
9
+ };
10
+ export type UpdateConfig = BuildConfig['config']['pjson']['oclif']['update'] & {
11
+ s3?: BuildConfig['config']['pjson']['oclif']['update']['s3'] & {
12
+ acl?: ObjectCannedACL;
13
+ };
14
+ };
3
15
  export interface BuildConfig {
4
16
  config: Interfaces.Config;
5
17
  dist(input: string): string;
@@ -7,16 +19,13 @@ export interface BuildConfig {
7
19
  nodeOptions: string[];
8
20
  nodeVersion: string;
9
21
  root: string;
10
- s3Config: BuildConfig['updateConfig']['s3'] & {
11
- folder?: string;
12
- indexVersionLimit?: number;
13
- };
22
+ s3Config: S3Config;
14
23
  targets: {
15
24
  arch: Interfaces.ArchTypes;
16
25
  platform: Interfaces.PlatformTypes;
17
26
  }[];
18
27
  tmp: string;
19
- updateConfig: BuildConfig['config']['pjson']['oclif']['update'];
28
+ updateConfig: UpdateConfig;
20
29
  workspace(target?: {
21
30
  arch: Interfaces.ArchTypes;
22
31
  platform: Interfaces.PlatformTypes;
@@ -28,7 +28,7 @@ async function buildConfig(root, options = {}) {
28
28
  const _gitSha = await gitSha(root, { short: true });
29
29
  // eslint-disable-next-line new-cap
30
30
  const tmp = await Tmp(config);
31
- const updateConfig = config.pjson.oclif.update || {};
31
+ const updateConfig = (config.pjson.oclif.update || {});
32
32
  updateConfig.s3 = updateConfig.s3 || {};
33
33
  const nodeVersion = updateConfig.node.version || process.versions.node;
34
34
  const nodeOptions = (0, util_1.castArray)(updateConfig.node.options ?? []);
@@ -44,6 +44,10 @@ async function buildConfig(root, options = {}) {
44
44
  const [platform, arch] = t.split('-');
45
45
  return { arch, platform };
46
46
  });
47
+ const s3Config = {
48
+ ...updateConfig.s3,
49
+ acl: updateConfig.s3.acl,
50
+ };
47
51
  return {
48
52
  config,
49
53
  dist: (...args) => path.join(config.root, 'dist', ...args),
@@ -51,7 +55,7 @@ async function buildConfig(root, options = {}) {
51
55
  nodeOptions,
52
56
  nodeVersion,
53
57
  root,
54
- s3Config: updateConfig.s3,
58
+ s3Config,
55
59
  targets,
56
60
  tmp,
57
61
  updateConfig,
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.appendToIndex = void 0;
4
+ const client_s3_1 = require("@aws-sdk/client-s3");
4
5
  const fs = require("fs-extra");
5
6
  const path = require("node:path");
6
7
  const aws_1 = require("./aws");
@@ -65,7 +66,7 @@ const appendToIndex = async (input) => {
65
66
  }, s3Config.indexVersionLimit), { spaces: 2 });
66
67
  // put the file back in the same place
67
68
  await aws_1.default.s3.uploadFile(jsonFileName, {
68
- ACL: s3Config.acl || 'public-read',
69
+ ACL: s3Config.acl ?? client_s3_1.ObjectCannedACL.public_read,
69
70
  Bucket: s3Config.bucket,
70
71
  CacheControl: maxAge,
71
72
  Key: key,
@@ -334,11 +334,26 @@
334
334
  "pack:deb": {
335
335
  "aliases": [],
336
336
  "args": {},
337
- "description": "pack CLI into debian package",
337
+ "description": "Pack CLI into debian package.",
338
338
  "flags": {
339
+ "compression": {
340
+ "char": "z",
341
+ "description": "For more details see the `-Zcompress-type` section at https://man7.org/linux/man-pages/man1/dpkg-deb.1.html",
342
+ "name": "compression",
343
+ "summary": "Override the default compression used by dpkg-deb.",
344
+ "hasDynamicHelp": false,
345
+ "multiple": false,
346
+ "options": [
347
+ "gzip",
348
+ "none",
349
+ "xz",
350
+ "zstd"
351
+ ],
352
+ "type": "option"
353
+ },
339
354
  "root": {
340
355
  "char": "r",
341
- "description": "path to oclif CLI root",
356
+ "description": "Path to oclif CLI root.",
342
357
  "name": "root",
343
358
  "required": true,
344
359
  "default": ".",
@@ -348,7 +363,7 @@
348
363
  },
349
364
  "tarball": {
350
365
  "char": "t",
351
- "description": "optionally specify a path to a tarball already generated by NPM",
366
+ "description": "Optionally specify a path to a tarball already generated by NPM.",
352
367
  "name": "tarball",
353
368
  "required": false,
354
369
  "hasDynamicHelp": false,
@@ -717,5 +732,5 @@
717
732
  ]
718
733
  }
719
734
  },
720
- "version": "4.2.0"
735
+ "version": "4.3.1"
721
736
  }
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "oclif",
3
3
  "description": "oclif: create your own CLI",
4
- "version": "4.2.0",
4
+ "version": "4.3.1",
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.468.0",
12
+ "@aws-sdk/client-s3": "^3.468.0",
11
13
  "@oclif/core": "^3.16.0",
12
14
  "@oclif/plugin-help": "^6.0.9",
13
- "@oclif/plugin-not-found": "^3.0.7",
15
+ "@oclif/plugin-not-found": "^3.0.8",
14
16
  "@oclif/plugin-warn-if-update-available": "^3.0.8",
15
17
  "async-retry": "^1.3.3",
16
- "aws-sdk": "^2.1231.0",
17
18
  "change-case": "^4",
18
19
  "debug": "^4.3.3",
19
20
  "eslint-plugin-perfectionist": "^2.1.0",