Skip to content

Commit

Permalink
fix: add back -h support (#104)
Browse files Browse the repository at this point in the history
* fix: add back -h support

To bring in plugin-help, I also reved @salesforce/core and @salesforce/command.
That then needed some minor updates for changes to the types.

* chore: switch from deprecated core.fs
  • Loading branch information
smithgp authored Apr 13, 2022
1 parent 0a6ef67 commit bf753e2
Show file tree
Hide file tree
Showing 38 changed files with 113 additions and 68 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"bugs": "https://github.com/forcedotcom/analyticsdx-vscode/issues",
"dependencies": {
"@oclif/config": "^1",
"@salesforce/command": "^3.1.3",
"@salesforce/core": "^2.25.1",
"@oclif/plugin-help": "^3.3.1",
"@salesforce/command": "^4.2.2",
"@salesforce/core": "^2.36.0",
"moment": "^2.24.0",
"tslib": "^2"
},
Expand Down
3 changes: 2 additions & 1 deletion src/commands/analytics/app/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { promises as fs } from 'fs';
import { EOL } from 'os';
import { flags, SfdxCommand } from '@salesforce/command';
import { fs, Messages, Org, SfdxError, StatusResult, StreamingClient } from '@salesforce/core';
import { Messages, Org, SfdxError, StatusResult, StreamingClient } from '@salesforce/core';
import { Duration } from '@salesforce/kit';
import { JsonMap } from '@salesforce/ts-types';
import chalk from 'chalk';
Expand Down
3 changes: 2 additions & 1 deletion src/commands/analytics/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { promises as fs } from 'fs';
import * as path from 'path';
import { flags, SfdxCommand } from '@salesforce/command';
import { fs, Messages, Org, SfdxError } from '@salesforce/core';
import { Messages, Org, SfdxError } from '@salesforce/core';
import QuerySvc, {
DRYRUN_FLAG,
LIMIT_FLAG,
Expand Down
17 changes: 9 additions & 8 deletions test/commands/app/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { core } from '@salesforce/command';
import { promises as fs } from 'fs';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';
import { AnyJson, ensureJsonMap, ensureString } from '@salesforce/ts-types';
import { StreamingClient } from '@salesforce/core';
Expand Down Expand Up @@ -188,7 +189,7 @@ describe('analytics:app:create', () => {
}
return Promise.reject();
})
.stub(core.fs, 'readFile', () =>
.stub(fs, 'readFile', () =>
Promise.resolve(
JSON.stringify({
templateSourceId: testTemplateJson.id,
Expand Down Expand Up @@ -222,7 +223,7 @@ describe('analytics:app:create', () => {
}
return Promise.reject();
})
.stub(core.fs, 'readFile', () =>
.stub(fs, 'readFile', () =>
Promise.resolve(
JSON.stringify({
templateSourceId: testTemplateJson.id,
Expand Down Expand Up @@ -256,7 +257,7 @@ describe('analytics:app:create', () => {
}
return Promise.reject();
})
.stub(core.fs, 'readFile', () =>
.stub(fs, 'readFile', () =>
Promise.resolve(
JSON.stringify({
assetIcon: '16.png',
Expand Down Expand Up @@ -300,7 +301,7 @@ describe('analytics:app:create', () => {
})
};
})
.stub(core.fs, 'readFile', () =>
.stub(fs, 'readFile', () =>
Promise.resolve(
JSON.stringify({
templateSourceId: testTemplateJson.id,
Expand Down Expand Up @@ -346,7 +347,7 @@ describe('analytics:app:create', () => {
}
};
})
.stub(core.fs, 'readFile', () =>
.stub(fs, 'readFile', () =>
Promise.resolve(
JSON.stringify({
templateSourceId: testTemplateJson.id,
Expand Down Expand Up @@ -396,7 +397,7 @@ describe('analytics:app:create', () => {
})
};
})
.stub(core.fs, 'readFile', () =>
.stub(fs, 'readFile', () =>
Promise.resolve(
JSON.stringify({
templateSourceId: testTemplateJson.id,
Expand Down Expand Up @@ -446,7 +447,7 @@ describe('analytics:app:create', () => {
}
};
})
.stub(core.fs, 'readFile', () =>
.stub(fs, 'readFile', () =>
Promise.resolve(
JSON.stringify({
templateSourceId: testTemplateJson.id,
Expand Down
2 changes: 1 addition & 1 deletion test/commands/app/decouple.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/commands/app/delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';
import { ensureJsonMap } from '@salesforce/ts-types';

Expand Down
2 changes: 1 addition & 1 deletion test/commands/app/display.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/commands/app/list.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';
import { ensureJsonMap, ensureString } from '@salesforce/ts-types';

Expand Down
2 changes: 1 addition & 1 deletion test/commands/app/update.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

const messages = core.Messages.loadMessages('@salesforce/analytics', 'app');
Expand Down
2 changes: 1 addition & 1 deletion test/commands/asset/publisher/create.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/commands/asset/publisher/deleteall.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';
import { ensureJsonMap } from '@salesforce/ts-types';

Expand Down
2 changes: 1 addition & 1 deletion test/commands/asset/publisher/list.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
3 changes: 2 additions & 1 deletion test/commands/autoinstall/app/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { core, UX } from '@salesforce/command';
import { UX } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';
import { SfdxError } from '@salesforce/core';
import { JsonMap } from '@salesforce/ts-types';
Expand Down
3 changes: 2 additions & 1 deletion test/commands/autoinstall/app/delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { core, UX } from '@salesforce/command';
import { UX } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';
import { SfdxError } from '@salesforce/core';
import { JsonMap } from '@salesforce/ts-types';
Expand Down
3 changes: 2 additions & 1 deletion test/commands/autoinstall/app/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { core, UX } from '@salesforce/command';
import { UX } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';
import { SfdxError } from '@salesforce/core';
import { JsonMap } from '@salesforce/ts-types';
Expand Down
2 changes: 1 addition & 1 deletion test/commands/autoinstall/list.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';
core.Messages.importMessagesDirectory(__dirname);
const messages = core.Messages.loadMessages('@salesforce/analytics', 'autoinstall');
Expand Down
2 changes: 1 addition & 1 deletion test/commands/dashboard/history/list.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/commands/dashboard/history/revert.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/commands/dashboard/list.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/commands/dashboard/update.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/commands/dataflow/history/list.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/commands/dataflow/history/revert.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/commands/dataflow/list.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/commands/dataset/display.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/commands/dataset/list.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/commands/dataset/rows/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// the test data is actual data from a server, which uses _ in field names
/* eslint-disable camelcase */

import { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';
import { SfdxError } from '@salesforce/core';
import { AnyJson, JsonMap, ensureJsonMap, ensureString } from '@salesforce/ts-types';
Expand Down
3 changes: 2 additions & 1 deletion test/commands/enable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { core, UX } from '@salesforce/command';
import { UX } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';
import { SfdxError } from '@salesforce/core';
import { JsonMap } from '@salesforce/ts-types';
Expand Down
2 changes: 1 addition & 1 deletion test/commands/lens/history/list.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/commands/lens/history/revert.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/commands/lens/list.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';

core.Messages.importMessagesDirectory(__dirname);
Expand Down
7 changes: 4 additions & 3 deletions test/commands/query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
// our test data is real data from a server, which uses _'s in the field names
/* eslint-disable camelcase */

import { core } from '@salesforce/command';
import { promises as fs } from 'fs';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';
import { SfdxError } from '@salesforce/core';
import { AnyJson, JsonMap, ensureJsonMap, ensureString } from '@salesforce/ts-types';
Expand Down Expand Up @@ -315,7 +316,7 @@ describe('analytics:query', () => {
}
return Promise.reject(new SfdxError('Invalid connection request'));
})
.stub(core.fs, 'readFile', () => Promise.resolve(sqlResponse.query))
.stub(fs, 'readFile', () => Promise.resolve(sqlResponse.query))
.stdout()
.stderr()
.command(['analytics:query', '-f', 'query.sql'])
Expand Down Expand Up @@ -348,7 +349,7 @@ describe('analytics:query', () => {
}
return Promise.reject(new SfdxError('Invalid connection request'));
})
.stub(core.fs, 'readFile', () => Promise.resolve('q = load "datasetname";'))
.stub(fs, 'readFile', () => Promise.resolve('q = load "datasetname";'))
.stderr()
.stdout()
.command(['analytics:query', '-f', 'query.saql'])
Expand Down
2 changes: 1 addition & 1 deletion test/commands/template/create.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';
import { AnyJson, ensureJsonMap, ensureString } from '@salesforce/ts-types';

Expand Down
2 changes: 1 addition & 1 deletion test/commands/template/delete.test.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 { core } from '@salesforce/command';
import * as core from '@salesforce/core';
import { expect, test } from '@salesforce/command/lib/test';
import { ensureJsonMap, ensureString } from '@salesforce/ts-types';

Expand Down
Loading

0 comments on commit bf753e2

Please sign in to comment.