Skip to content

Commit

Permalink
chore: new sf migrate command ran
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Oct 26, 2023
1 parent e0c73db commit c41c897
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ node_modules
oclif.manifest.json

oclif.lock

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.

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" %*
2 changes: 1 addition & 1 deletion bin/dev.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ts-node
#!/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');
Expand Down
1 change: 1 addition & 0 deletions bin/run.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/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 });
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/core": "^3.8.0",
"@oclif/core": "^3.9.0",
"@salesforce/core": "^5.3.10",
"@salesforce/sf-plugins-core": "^4.0.0",
"got": "^13.0.0",
Expand Down Expand Up @@ -36,7 +36,7 @@
"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-dev.1",
"eslint-config-salesforce-typescript": "^2.0.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-jsdoc": "^46.8.2",
Expand All @@ -63,6 +63,7 @@
"/lib",
"/messages",
"/oclif.manifest.json",
"/oclif.lock",
"/oclif.lock"
],
"homepage": "https://github.com/salesforcecli/plugin-trust",
Expand Down
4 changes: 3 additions & 1 deletion src/commands/plugins/trust/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* 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 {
Expand All @@ -15,7 +17,7 @@ import {
import { NpmName } from '../../../shared/NpmName.js';
import { setErrorName } from '../../../shared/errors.js';

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

export interface VerifyResponse {
Expand Down
5 changes: 3 additions & 2 deletions src/shared/installationVerification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { URL } from 'node:url';
import * as crypto from 'node:crypto';
import * as 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';
Expand All @@ -19,11 +21,10 @@ import { ux } from '@oclif/core';
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
10 changes: 6 additions & 4 deletions test/nuts/plugin-install.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
* 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 * as fs from 'node:fs';
import * as os from 'node:os';
import path from 'node:path';
import fs from 'node:fs';
import os from 'node:os';
import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
import { expect, config } from 'chai';
import { TestSession, execCmd, execInteractiveCmd, Interaction } from '@salesforce/cli-plugins-testkit';
import { Messages } from '@salesforce/core';

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

config.truncateThreshold = 0;
Expand Down
4 changes: 3 additions & 1 deletion test/shared/installationVerification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
import { Readable } from 'node:stream';
import * as fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
import { assert, expect } from 'chai';
import got from 'got';
import { OptionsOfTextResponseBody } from 'got';
Expand Down Expand Up @@ -130,7 +132,7 @@ describe('InstallationVerification Tests', () => {
return 'configDir';
},
get cliRoot() {
return __dirname;
return dirname(fileURLToPath(import.meta.url));
},
};
const currentRegistry = process.env.SFDX_NPM_REGISTRY;
Expand Down
46 changes: 34 additions & 12 deletions test/shared/npmCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import { fail } from 'node:assert';
import * as os from 'node:os';
import * as fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
import { expect, assert } from 'chai';
import * as Sinon from 'sinon';
import * as shelljs from 'shelljs';
Expand Down Expand Up @@ -100,23 +102,29 @@ describe('should run npm commands', () => {
});

it('Runs the show command', () => {
const npmMetadata = new NpmModule(MODULE_NAME, undefined, __dirname).show(DEFAULT_REGISTRY);
const npmMetadata = new NpmModule(MODULE_NAME, undefined, dirname(fileURLToPath(import.meta.url))).show(
DEFAULT_REGISTRY
);
expect(shelljsExecStub).to.have.been.calledOnce;
expect(shelljsExecStub.firstCall.args[0]).to.include(`show ${MODULE_NAME}@latest`);
expect(shelljsExecStub.firstCall.args[0]).to.include(`--registry=${DEFAULT_REGISTRY}`);
expect(npmMetadata).to.deep.equal(SHOW_RESULT);
});

it('Runs the show command with specified version', () => {
const npmMetadata = new NpmModule(MODULE_NAME, MODULE_VERSION, __dirname).show(DEFAULT_REGISTRY);
const npmMetadata = new NpmModule(MODULE_NAME, MODULE_VERSION, dirname(fileURLToPath(import.meta.url))).show(
DEFAULT_REGISTRY
);
expect(shelljsExecStub).to.have.been.calledOnce;
expect(shelljsExecStub.firstCall.args[0]).to.include(`show ${MODULE_NAME}@${MODULE_VERSION}`);
expect(shelljsExecStub.firstCall.args[0]).to.include(`--registry=${DEFAULT_REGISTRY}`);
expect(npmMetadata).to.deep.equal(SHOW_RESULT);
});

it('Runs the pack command', () => {
new NpmModule(MODULE_NAME, MODULE_VERSION, __dirname).pack(DEFAULT_REGISTRY, { cwd: CACHE_PATH });
new NpmModule(MODULE_NAME, MODULE_VERSION, dirname(fileURLToPath(import.meta.url))).pack(DEFAULT_REGISTRY, {
cwd: CACHE_PATH,
});
expect(shelljsExecStub).to.have.been.calledOnce;
expect(shelljsExecStub.firstCall.args[0]).to.include(`pack ${MODULE_NAME}@${MODULE_VERSION}`);
expect(shelljsExecStub.firstCall.args[0]).to.include(`--registry=${DEFAULT_REGISTRY}`);
Expand Down Expand Up @@ -185,7 +193,9 @@ describe('should find the node executable', () => {
});

it('finds node binary inside sfdx bin folder and runs npm show command', () => {
const npmMetadata = new NpmModule(MODULE_NAME, undefined, __dirname).show(DEFAULT_REGISTRY);
const npmMetadata = new NpmModule(MODULE_NAME, undefined, dirname(fileURLToPath(import.meta.url))).show(
DEFAULT_REGISTRY
);
expect(accessSyncStub).to.have.been.calledOnce;
expect(existsSyncStub).to.have.been.calledTwice;
expect(osTypeStub).to.have.been.calledOnce;
Expand All @@ -202,7 +212,9 @@ describe('should find the node executable', () => {
shelljsFindStub.returns(['C:\\Program Files\\sfdx\\client\\bin\\node.exe']);
osTypeStub.returns('Windows_NT');

const npmMetadata = new NpmModule(MODULE_NAME, undefined, __dirname).show(DEFAULT_REGISTRY);
const npmMetadata = new NpmModule(MODULE_NAME, undefined, dirname(fileURLToPath(import.meta.url))).show(
DEFAULT_REGISTRY
);
expect(accessSyncStub).to.not.have.been.called;
expect(existsSyncStub).to.have.been.calledTwice;
expect(osTypeStub).to.have.been.calledOnce;
Expand All @@ -228,7 +240,9 @@ describe('should find the node executable', () => {
code: 0,
} as shelljs.ShellString;
});
const npmMetadata = new NpmModule(MODULE_NAME, undefined, __dirname).show(DEFAULT_REGISTRY);
const npmMetadata = new NpmModule(MODULE_NAME, undefined, dirname(fileURLToPath(import.meta.url))).show(
DEFAULT_REGISTRY
);
expect(existsSyncStub).to.have.been.calledTwice;
expect(shelljsFindStub).to.not.have.been.called;
expect(realpathSyncStub).to.not.have.been.called;
Expand All @@ -252,7 +266,9 @@ describe('should find the node executable', () => {
return null;
});
try {
const npmMetadata = new NpmModule(MODULE_NAME, undefined, __dirname).show(DEFAULT_REGISTRY);
const npmMetadata = new NpmModule(MODULE_NAME, undefined, dirname(fileURLToPath(import.meta.url))).show(
DEFAULT_REGISTRY
);
expect(npmMetadata).to.be.undefined;
fail('Error');
} catch (error) {
Expand Down Expand Up @@ -304,7 +320,9 @@ describe('should run npm commands with execution errors', () => {

it('show command throws error', () => {
try {
const npmMetadata = new NpmModule(MODULE_NAME, undefined, __dirname).show(DEFAULT_REGISTRY);
const npmMetadata = new NpmModule(MODULE_NAME, undefined, dirname(fileURLToPath(import.meta.url))).show(
DEFAULT_REGISTRY
);
expect(npmMetadata).to.be.undefined;
fail('Error');
} catch (error) {
Expand All @@ -315,7 +333,9 @@ describe('should run npm commands with execution errors', () => {

it('Runs the pack command', () => {
try {
new NpmModule(MODULE_NAME, MODULE_VERSION, __dirname).pack(DEFAULT_REGISTRY, { cwd: CACHE_PATH });
new NpmModule(MODULE_NAME, MODULE_VERSION, dirname(fileURLToPath(import.meta.url))).pack(DEFAULT_REGISTRY, {
cwd: CACHE_PATH,
});
fail('Error');
} catch (error) {
assert(error instanceof SfError);
Expand Down Expand Up @@ -363,7 +383,9 @@ describe('should run npm commands with parse errors', () => {

it('show command throws error', () => {
try {
const npmMetadata = new NpmModule(MODULE_NAME, MODULE_VERSION, __dirname).show(DEFAULT_REGISTRY);
const npmMetadata = new NpmModule(MODULE_NAME, MODULE_VERSION, dirname(fileURLToPath(import.meta.url))).show(
DEFAULT_REGISTRY
);
expect(npmMetadata).to.be.undefined;
fail('Error');
} catch (error) {
Expand Down Expand Up @@ -402,7 +424,7 @@ describe('should run npm commands with npm errors', () => {

it('show command throws error', () => {
try {
new NpmModule(MODULE_NAME, MODULE_VERSION, __dirname).show(DEFAULT_REGISTRY);
new NpmModule(MODULE_NAME, MODULE_VERSION, dirname(fileURLToPath(import.meta.url))).show(DEFAULT_REGISTRY);
} catch (error) {
assert(error instanceof SfError);
expect(error.code).to.equal('NpmError');
Expand All @@ -412,7 +434,7 @@ describe('should run npm commands with npm errors', () => {

it('pack command throws error', () => {
try {
new NpmModule(MODULE_NAME, MODULE_VERSION, __dirname).pack(DEFAULT_REGISTRY);
new NpmModule(MODULE_NAME, MODULE_VERSION, dirname(fileURLToPath(import.meta.url))).pack(DEFAULT_REGISTRY);
} catch (error) {
assert(error instanceof SfError);
expect(error.code).to.equal('NpmError');
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -966,10 +966,10 @@
wordwrap "^1.0.0"
wrap-ansi "^7.0.0"

"@oclif/core@^3.0.0", "@oclif/core@^3.0.4", "@oclif/core@^3.3.1", "@oclif/core@^3.5.0", "@oclif/core@^3.8.0":
version "3.8.0"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.8.0.tgz#45f5f630b3b593c3486e7835953ad6fb2af01bcb"
integrity sha512-fKqg9QzjIflDcYljZkZEeY6zoRyk4AZ5e2V4LUIsSOR7+B78qpqNqDPJFTI8TvrEU3+Q+ssELntOL2VA3SMsqQ==
"@oclif/core@^3.0.0", "@oclif/core@^3.0.4", "@oclif/core@^3.3.1", "@oclif/core@^3.5.0", "@oclif/core@^3.9.0":
version "3.9.0"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.9.0.tgz#51c53ea4eafd3d643a55a37477f3e7c9d2cc2942"
integrity sha512-9UT0ySJgaUvERUQwDFh0u9Q5cfoBttfyaJ1sorSms6H5AELIjQ2Yvu2QfzPmnAit2rod+hdcDZ+O1Hia5Zcz+Q==
dependencies:
ansi-escapes "^4.3.2"
ansi-styles "^4.3.0"
Expand Down Expand Up @@ -3551,7 +3551,7 @@ eslint-config-salesforce-license@^0.2.0:
resolved "https://registry.yarnpkg.com/eslint-config-salesforce-license/-/eslint-config-salesforce-license-0.2.0.tgz#323193f1aa15dd33fbf108d25fc1210afc11065e"
integrity sha512-DJdBvgj82Erum82YMe+YvG/o6ukna3UA++lRl0HSTldj0VlBl3Q8hzCp97nRXZHra6JH1I912yievZzklXDw6w==

eslint-config-salesforce-typescript@^2.0.0, eslint-config-salesforce-typescript@^2.0.0-dev.1:
eslint-config-salesforce-typescript@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/eslint-config-salesforce-typescript/-/eslint-config-salesforce-typescript-2.0.0.tgz#df6cd54c7d5254158e0c175a8a3526d3f9510b56"
integrity sha512-1gq4ChEamP3VaDXoMJdEUX92fOdNMjX9/xOfByOO5AsQJnakRE/P4LWQrw5QqQQGWU8YnnM/OADFI9otD002aQ==
Expand Down

0 comments on commit c41c897

Please sign in to comment.