Skip to content

Commit

Permalink
Wr/esm (#633)
Browse files Browse the repository at this point in the history
* feat!: migrate to esm

* chore: building

* chore: new sf migrate command ran

* test: fixing UTs, 3 left

* test: fix UT

* chore: review comments

* chore: mike's updates

* chore: bump dev-scripts, core

---------

Co-authored-by: mshanemc <[email protected]>
  • Loading branch information
WillieRuemmele and mshanemc authored Nov 2, 2023
1 parent 4efdbcd commit cb32533
Show file tree
Hide file tree
Showing 26 changed files with 1,153 additions and 1,433 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ node_modules
.idea

oclif.manifest.json

oclif.lock
3 changes: 3 additions & 0 deletions .lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'**/*.{js,json,md}?(x)': () => 'npm run reformat',
};
3 changes: 0 additions & 3 deletions .lintstagedrc.js

This file was deleted.

16 changes: 12 additions & 4 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
{
"require": "ts-node/register,source-map-support/register",
"require": [
"ts-node/register"
],
"watch-extensions": "ts",
"watch-files": ["src", "test"],
"watch-files": [
"src",
"test"
],
"recursive": true,
"reporter": "spec",
"timeout": 10000
}
"timeout": 10000,
"node-option": [
"loader=ts-node/esm"
]
}
21 changes: 0 additions & 21 deletions bin/dev

This file was deleted.

2 changes: 1 addition & 1 deletion bin/dev.cmd
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off

node "%~dp0\dev" %*
node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
8 changes: 8 additions & 0 deletions bin/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
// eslint-disable-next-line node/shebang
async function main() {
const { execute } = await import('@oclif/core');
await execute({ development: true, dir: import.meta.url });
}

await main();
3 changes: 0 additions & 3 deletions bin/run

This file was deleted.

2 changes: 1 addition & 1 deletion bin/run.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off

node "%~dp0\run" %*
node "%~dp0\run" %*
9 changes: 9 additions & 0 deletions bin/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env node

// eslint-disable-next-line node/shebang
async function main() {
const { execute } = await import('@oclif/core');
await execute({ dir: import.meta.url });
}

await main();
File renamed without changes.
74 changes: 29 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,56 @@
"description": "validate a digital signature for a npm package",
"version": "2.6.22",
"author": "Salesforce",
"main": "lib/index.js",
"bin": {
"sf-trust": "bin/dev"
},
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/core": "^2.15.0",
"@salesforce/core": "^5.3.10",
"@salesforce/sf-plugins-core": "^3.1.23",
"got": "^11",
"@oclif/core": "^3.9.0",
"@salesforce/core": "^5.3.16",
"@salesforce/sf-plugins-core": "^4.0.0",
"got": "^13.0.0",
"npm": "9.8.1",
"npm-run-path": "^4.0.1",
"proxy-agent": "^6.3.1",
"shelljs": "^0.8.4",
"tslib": "^2"
"shelljs": "^0.8.4"
},
"devDependencies": {
"@oclif/plugin-command-snapshot": "^4.0.14",
"@salesforce/cli-plugins-testkit": "^4.4.10",
"@salesforce/dev-config": "^4.0.1",
"@salesforce/dev-scripts": "^5.12.2",
"@oclif/plugin-command-snapshot": "^5.0.1",
"@salesforce/cli-plugins-testkit": "^5.0.0-dev.1",
"@salesforce/dev-scripts": "^6.0.3",
"@salesforce/plugin-command-reference": "^3.0.43",
"@salesforce/plugin-telemetry": "^2.3.8",
"@salesforce/prettier-config": "^0.0.3",
"@salesforce/ts-sinon": "^1.4.18",
"@swc/core": "1.3.39",
"@types/shelljs": "^0.8.9",
"@types/sinon-chai": "^3.2.11",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.61.0",
"chai": "^4.3.10",
"eslint": "^8.52.0",
"eslint-config-prettier": "^8.10.0",
"eslint-config-salesforce": "^2.0.2",
"eslint-config-salesforce-license": "^0.2.0",
"eslint-config-salesforce-typescript": "^2.0.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-jsdoc": "^46.8.2",
"eslint-plugin-sf-plugin": "^1.16.9",
"husky": "^7.0.4",
"mocha": "^9.1.3",
"nyc": "^15.1.0",
"oclif": "^3.17.2",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.0",
"eslint-plugin-sf-plugin": "^1.16.13",
"oclif": "^4.0.3",
"shx": "0.3.4",
"sinon": "10.0.0",
"sinon-chai": "^3.7.0",
"ts-node": "^10.0.0",
"typescript": "^5.2.2",
"wireit": "^0.14.1"
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
},
"config": {},
"engines": {
"node": ">=16.0.0"
"node": ">=18.0.0"
},
"files": [
"bin",
"/lib",
"/messages",
"/oclif.manifest.json"
"/oclif.manifest.json",
"/oclif.lock"
],
"homepage": "https://github.com/salesforcecli/plugin-trust",
"keywords": [
"force",
"salesforce",
"sfdx",
"salesforcedx",
"sfdx-plugin"
"sfdx-plugin",
"sf",
"sf-plugin"
],
"license": "BSD-3-Clause",
"oclif": {
Expand All @@ -97,19 +77,21 @@
}
}
}
}
},
"flexibleTaxonomy": true,
"topicSeparator": " "
},
"repository": "salesforcecli/plugin-trust",
"scripts": {
"build": "wireit",
"clean": "sf-clean",
"clean-all": "sf-clean all",
"clean:lib": "shx rm -rf lib && shx rm -rf coverage && shx rm -rf .nyc_output && shx rm -f oclif.manifest.json",
"clean:lib": "shx rm -rf lib && shx rm -rf coverage && shx rm -rf .nyc_output && shx rm -f oclif.manifest.json oclif.lock",
"compile": "wireit",
"docs": "sf-docs",
"format": "wireit",
"lint": "wireit",
"postpack": "shx rm -f oclif.manifest.json",
"postpack": "shx rm -f oclif.manifest.json oclif.lock",
"prepack": "sf-prepack",
"prepare": "sf-install",
"test": "wireit",
Expand Down Expand Up @@ -196,7 +178,7 @@
"output": []
},
"test:command-reference": {
"command": "\"./bin/dev\" commandreference:generate --erroronwarnings",
"command": "ts-node \"./bin/dev.js\" commandreference:generate --erroronwarnings",
"files": [
"src/**/*.ts",
"messages/**",
Expand All @@ -207,7 +189,7 @@
]
},
"test:deprecation-policy": {
"command": "\"./bin/dev\" snapshot:compare",
"command": "ts-node \"./bin/dev.js\" snapshot:compare",
"files": [
"src/**/*.ts"
],
Expand All @@ -217,12 +199,14 @@
]
},
"test:json-schema": {
"command": "\"./bin/dev\" schema:compare",
"command": "ts-node \"./bin/dev.js\" schema:compare",
"files": [
"src/**/*.ts",
"schemas"
],
"output": []
}
}
},
"exports": "./lib/index.js",
"type": "module"
}
16 changes: 11 additions & 5 deletions src/commands/plugins/trust/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
import { SfCommand, Flags, loglevel } from '@salesforce/sf-plugins-core';
import { Messages, SfError, Logger } from '@salesforce/core';
import { ConfigContext, InstallationVerification, VerificationConfig } from '../../../shared/installationVerification';
import { NpmName } from '../../../shared/NpmName';
import { setErrorName } from '../../../shared/errors';

Messages.importMessagesDirectory(__dirname);
import {
ConfigContext,
InstallationVerification,
VerificationConfig,
} from '../../../shared/installationVerification.js';
import { NpmName } from '../../../shared/NpmName.js';
import { setErrorName } from '../../../shared/errors.js';

Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
const messages = Messages.loadMessages('@salesforce/plugin-trust', 'verify');

export interface VerifyResponse {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/jitPluginInstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { homedir } from 'node:os';
import { Hook } from '@oclif/core';
import { SfError } from '@salesforce/core';
import { TelemetryGlobal } from '@salesforce/plugin-telemetry/lib/telemetryGlobal';
import { TelemetryGlobal } from '@salesforce/plugin-telemetry/lib/telemetryGlobal.js';

declare const global: TelemetryGlobal;

Expand Down
4 changes: 2 additions & 2 deletions src/hooks/verifyInstallSignature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
doPrompt,
InstallationVerification,
VerificationConfig,
} from '../shared/installationVerification';
} from '../shared/installationVerification.js';

import { NpmName } from '../shared/NpmName';
import { NpmName } from '../shared/NpmName.js';

export const hook: Hook.PluginsPreinstall = async function (options) {
if (options.plugin && options.plugin.type === 'npm') {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

export = {};
export default {};
2 changes: 1 addition & 1 deletion src/shared/NpmName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { SfError } from '@salesforce/core';
import { setErrorName } from './errors';
import { setErrorName } from './errors.js';

interface NpmNameInfo {
scope: string;
Expand Down
17 changes: 9 additions & 8 deletions src/shared/installationVerification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import * as path from 'node:path';
import path from 'node:path';
import { Readable } from 'node:stream';
import { URL } from 'node:url';
import * as crypto from 'node:crypto';
import * as fs from 'node:fs';
import crypto from 'node:crypto';
import fs from 'node:fs';
import { mkdir } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
import { Logger, SfError, Messages } from '@salesforce/core';
import got from 'got';
import { ProxyAgent } from 'proxy-agent';
import { Prompter } from '@salesforce/sf-plugins-core';
import { ux } from '@oclif/core';
import { NpmModule, NpmMeta } from '../shared/npmCommand';
import { NpmName } from './NpmName';
import { setErrorName } from './errors';

import { NpmModule, NpmMeta } from './npmCommand.js';
import { NpmName } from './NpmName.js';
import { setErrorName } from './errors.js';
const CRYPTO_LEVEL = 'RSA-SHA256';
const ALLOW_LIST_FILENAME = 'unsignedPluginAllowList.json';
export const DEFAULT_REGISTRY = 'https://registry.npmjs.org/';
Messages.importMessagesDirectory(__dirname);
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));

export interface ConfigContext {
configDir?: string;
Expand Down
Loading

0 comments on commit cb32533

Please sign in to comment.