Skip to content

Commit 4927382

Browse files
feat!: esm, core7 (#600)
* chore: updates from devScripts * feat: esm * chore: linkinator * chore: bin/run for generate * chore: core 7 * test: use bin/dev * chore: bump plugin-auth * chore: bump oclif/core, etc * ci: no ts-noe for cmd-ref * test: windows ut via node command * chore: bump plugin-auth for new plugin-info --------- Co-authored-by: svc-cli-bot <[email protected]>
1 parent 170e08e commit 4927382

20 files changed

+834
-619
lines changed

.mocharc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2-
"require": "ts-node/register,source-map-support/register",
2+
"require": ["ts-node/register"],
33
"watch-extensions": "ts",
44
"recursive": true,
55
"reporter": "spec",
6-
"timeout": 15000
6+
"timeout": 15000,
7+
"node-option": ["loader=ts-node/esm"]
78
}

.sfdevrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
},
55
"wireit": {
66
"test:command-reference": {
7-
"command": "ts-node \"./bin/dev.js\" commandreference:generate --plugins auth --outputdir test/tmp",
7+
"command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" commandreference generate --plugins auth --outputdir test/tmp",
88
"files": ["src/**/*.ts", "messages/**", "package.json"],
99
"output": ["test/tmp"]
1010
},

bin/dev.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
#!/usr/bin/env ts-node
2-
// eslint-disable-next-line node/shebang, unicorn/prefer-top-level-await
3-
(async () => {
4-
const oclif = await import('@oclif/core');
5-
await oclif.execute({ development: true, dir: __dirname });
6-
})();
1+
#!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
2+
// eslint-disable-next-line node/shebang
3+
async function main() {
4+
const { execute } = await import('@oclif/core');
5+
await execute({ development: true, dir: import.meta.url });
6+
}
7+
8+
await main();

bin/run.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env node
22

3-
// eslint-disable-next-line unicorn/prefer-top-level-await
4-
(async () => {
5-
const oclif = await import('@oclif/core');
6-
await oclif.execute({ development: false, dir: __dirname });
7-
})();
3+
// eslint-disable-next-line node/shebang
4+
async function main() {
5+
const { execute } = await import('@oclif/core');
6+
await execute({ dir: import.meta.url });
7+
}
8+
9+
await main();

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,29 @@
44
"version": "3.0.75",
55
"author": "Salesforce",
66
"bugs": "https://github.com/salesforcecli/plugin-command-reference/issues",
7+
"type": "module",
78
"dependencies": {
8-
"@oclif/core": "^3.26.0",
9-
"@salesforce/core": "^6.7.6",
9+
"@oclif/core": "^3.26.2",
10+
"@salesforce/core": "^7.1.0",
1011
"@salesforce/kit": "^3.1.0",
11-
"@salesforce/sf-plugins-core": "^5.0.13",
12+
"@salesforce/sf-plugins-core": "^9.0.1",
1213
"@salesforce/ts-types": "^2.0.9",
13-
"chalk": "^4",
14+
"chalk": "^5.3.0",
1415
"debug": "^4.3.4",
15-
"handlebars": "^4.7.8",
16-
"tslib": "^2"
16+
"handlebars": "^4.7.8"
1717
},
1818
"devDependencies": {
19-
"@oclif/plugin-help": "^6",
19+
"@oclif/plugin-help": "^6.0.20",
2020
"@salesforce/dev-scripts": "^8.5.0",
21-
"@salesforce/plugin-auth": "^2.8.26",
21+
"@salesforce/plugin-auth": "^3.6.1",
2222
"@types/debug": "^4.1.12",
23-
"@types/ejs": "^3.1.5",
24-
"eslint-plugin-sf-plugin": "^1.17.5",
25-
"oclif": "^4",
23+
"eslint-plugin-sf-plugin": "^1.18.0",
24+
"oclif": "^4.8.0",
2625
"ts-node": "^10.9.2",
2726
"typescript": "^5.4.4"
2827
},
2928
"engines": {
30-
"node": ">=16.0.0"
29+
"node": ">=18.0.0"
3130
},
3231
"files": [
3332
"/lib",
@@ -44,6 +43,7 @@
4443
"license": "BSD-3-Clause",
4544
"oclif": {
4645
"commands": "./lib/commands",
46+
"flexibleTaxonomy": true,
4747
"bin": "sf",
4848
"topicSeparator": " ",
4949
"topics": {
@@ -157,7 +157,7 @@
157157
]
158158
},
159159
"test:command-reference": {
160-
"command": "ts-node \"./bin/dev.js\" commandreference:generate --plugins auth --outputdir test/tmp",
160+
"command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" commandreference generate --plugins auth --outputdir test/tmp",
161161
"files": [
162162
"src/**/*.ts",
163163
"messages/**",

src/commands/commandreference/generate.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import * as os from 'node:os';
8+
import os from 'node:os';
99
import { resolve } from 'node:path';
1010
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
1111
// eslint-disable-next-line sf-plugin/no-oclif-flags-command-import
1212
import { Command, Config, Interfaces } from '@oclif/core';
1313
import { Messages, SfError } from '@salesforce/core';
1414
import { AnyJson, ensure } from '@salesforce/ts-types';
15-
import chalk = require('chalk');
15+
import chalk from 'chalk';
1616
import { PJSON } from '@oclif/core/lib/interfaces';
17-
import { Ditamap } from '../../ditamap/ditamap';
18-
import { Docs } from '../../docs';
19-
import { CliMeta, CommandClass, events, SfTopic, SfTopics } from '../../utils';
17+
import { Ditamap } from '../../ditamap/ditamap.js';
18+
import { Docs } from '../../docs.js';
19+
import { CliMeta, CommandClass, events, SfTopic, SfTopics } from '../../utils.js';
2020

2121
// Initialize Messages with the current plugin directory
22-
Messages.importMessagesDirectory(__dirname);
22+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
2323
const messages = Messages.loadMessages('@salesforce/plugin-command-reference', 'main');
2424

2525
export type CommandReferenceGenerateResults = {
@@ -156,7 +156,7 @@ export default class CommandReferenceGenerate extends SfCommand<CommandReference
156156
await docs.build(commands);
157157
this.log(`\nWrote generated doc to ${Ditamap.outputDir}`);
158158

159-
if (flags.erroronwarnings && warnings.length > 0) {
159+
if (flags['error-on-warnings'] && warnings.length > 0) {
160160
throw new SfError(`Found ${warnings.length} warnings.`);
161161
}
162162

src/commands/jit/install.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
99
import { Messages } from '@salesforce/core';
10-
import * as chalk from 'chalk';
10+
import chalk from 'chalk';
1111

12-
Messages.importMessagesDirectory(__dirname);
12+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
1313
const messages = Messages.loadMessages('@salesforce/plugin-command-reference', 'jit.install');
1414

1515
export default class JitInstall extends SfCommand<void> {

src/ditamap/base-ditamap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import { Ditamap } from './ditamap';
8+
import { Ditamap } from './ditamap.js';
99

1010
export class BaseDitamap extends Ditamap {
1111
public constructor(topics: string[]) {

src/ditamap/cli-reference.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import { Ditamap } from './ditamap';
8+
import { Ditamap } from './ditamap.js';
99

1010
export class CLIReference extends Ditamap {
1111
public constructor() {

0 commit comments

Comments
 (0)