oclif 3.15.1 → 3.16.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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.15.1",
2
+ "version": "3.16.0",
3
3
  "commands": {
4
4
  "generate": {
5
5
  "id": "generate",
@@ -173,6 +173,18 @@
173
173
  "type": "boolean",
174
174
  "description": "include aliases in the command list",
175
175
  "allowNo": true
176
+ },
177
+ "repository-prefix": {
178
+ "name": "repository-prefix",
179
+ "type": "option",
180
+ "description": "a template string used to build links to the source code",
181
+ "multiple": false
182
+ },
183
+ "version": {
184
+ "name": "version",
185
+ "type": "option",
186
+ "description": "version to use in readme links. defaults to the version in package.json",
187
+ "multiple": false
176
188
  }
177
189
  },
178
190
  "args": {}
@@ -5,8 +5,11 @@ export default class Readme extends Command {
5
5
  dir: Interfaces.OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
6
  multi: Interfaces.BooleanFlag<boolean>;
7
7
  aliases: Interfaces.BooleanFlag<boolean>;
8
+ 'repository-prefix': Interfaces.OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ version: Interfaces.OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
10
  };
9
11
  private HelpClass;
12
+ private flags;
10
13
  run(): Promise<void>;
11
14
  replaceTag(readme: string, tag: string, body: string): string;
12
15
  toc(__: Interfaces.Config, readme: string): string;
@@ -13,7 +13,7 @@ const columns = Number.parseInt(process.env.COLUMNS, 10) || 120;
13
13
  const slugify = new (require('github-slugger'))();
14
14
  class Readme extends core_1.Command {
15
15
  async run() {
16
- const { flags } = await this.parse(Readme);
16
+ this.flags = (await this.parse(Readme)).flags;
17
17
  const cwd = process.cwd();
18
18
  const readmePath = path.resolve(cwd, 'README.md');
19
19
  const config = await core_1.Config.load({ root: cwd, devPlugins: false, userPlugins: false });
@@ -29,13 +29,13 @@ class Readme extends core_1.Command {
29
29
  let readme = await fs.readFile(readmePath, 'utf8');
30
30
  let commands = config.commands
31
31
  .filter(c => !c.hidden && c.pluginType === 'core')
32
- .filter(c => flags.aliases ? true : !c.aliases.includes(c.id))
32
+ .filter(c => this.flags.aliases ? true : !c.aliases.includes(c.id))
33
33
  .map(c => c.id === '.' ? Object.assign(Object.assign({}, c), { id: '' }) : c);
34
34
  this.debug('commands:', commands.map(c => c.id).length);
35
35
  commands = (0, util_1.uniqBy)(commands, c => c.id);
36
36
  commands = (0, util_1.sortBy)(commands, c => c.id);
37
37
  readme = this.replaceTag(readme, 'usage', this.usage(config));
38
- readme = this.replaceTag(readme, 'commands', flags.multi ? this.multiCommands(config, commands, flags.dir) : this.commands(config, commands));
38
+ readme = this.replaceTag(readme, 'commands', this.flags.multi ? this.multiCommands(config, commands, this.flags.dir) : this.commands(config, commands));
39
39
  readme = this.replaceTag(readme, 'toc', this.toc(config, readme));
40
40
  readme = readme.trimEnd();
41
41
  readme += '\n';
@@ -66,7 +66,7 @@ $ npm install -g ${config.name}
66
66
  $ ${config.bin} COMMAND
67
67
  running command...
68
68
  $ ${config.bin} ${versionFlagsString}
69
- ${config.name}/${process.env.OCLIF_NEXT_VERSION || config.version} ${process.platform}-${process.arch} node-v${process.versions.node}
69
+ ${config.name}/${this.flags.version || config.version} ${process.platform}-${process.arch} node-v${process.versions.node}
70
70
  $ ${config.bin} --help [COMMAND]
71
71
  USAGE
72
72
  $ ${config.bin} COMMAND
@@ -156,9 +156,9 @@ USAGE
156
156
  return;
157
157
  if (config.name === plugin.name) {
158
158
  label = commandPath;
159
- version = process.env.OCLIF_NEXT_VERSION || version;
159
+ version = this.flags.version || version;
160
160
  }
161
- const template = plugin.pjson.oclif.repositoryPrefix || '<%- repo %>/blob/v<%- version %>/<%- commandPath %>';
161
+ const template = this.flags['repository-prefix'] || plugin.pjson.oclif.repositoryPrefix || '<%- repo %>/blob/v<%- version %>/<%- commandPath %>';
162
162
  return `_See code: [${label}](${_.template(template)({ repo, version, commandPath, config, c })})_`;
163
163
  }
164
164
  repo(plugin) {
@@ -168,7 +168,7 @@ USAGE
168
168
  if (!repo)
169
169
  return;
170
170
  const url = new url_1.URL(repo);
171
- if (!['github.com', 'gitlab.com'].includes(url.hostname) && !pjson.oclif.repositoryPrefix)
171
+ if (!['github.com', 'gitlab.com'].includes(url.hostname) && !pjson.oclif.repositoryPrefix && !this.flags['repository-prefix'])
172
172
  return;
173
173
  return `https://${url.hostname}${url.pathname.replace(/\.git$/, '')}`;
174
174
  }
@@ -245,4 +245,6 @@ Readme.flags = {
245
245
  dir: core_1.Flags.string({ description: 'output directory for multi docs', default: 'docs', required: true }),
246
246
  multi: core_1.Flags.boolean({ description: 'create a different markdown page for each topic' }),
247
247
  aliases: core_1.Flags.boolean({ description: 'include aliases in the command list', allowNo: true, default: true }),
248
+ 'repository-prefix': core_1.Flags.string({ description: 'a template string used to build links to the source code' }),
249
+ version: core_1.Flags.string({ description: 'version to use in readme links. defaults to the version in package.json', env: 'OCLIF_NEXT_VERSION' }),
248
250
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "oclif",
3
3
  "description": "oclif: create your own CLI",
4
- "version": "3.15.1",
4
+ "version": "3.16.0",
5
5
  "author": "Salesforce",
6
6
  "bin": {
7
7
  "oclif": "bin/run"