Skip to content

Commit

Permalink
Merge pull request #439 from salesforcecli/wr/esm
Browse files Browse the repository at this point in the history
Wr/esm
  • Loading branch information
mshanemc authored Nov 6, 2023
2 parents 0a8f4c1 + 4881160 commit aa4f41b
Show file tree
Hide file tree
Showing 32 changed files with 2,015 additions and 1,653 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.cjs/
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
File renamed without changes.
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/**/*.ts", "test/**/*.ts"],
"watch-files": [
"src/**/*.ts",
"test/**/*.ts"
],
"recursive": true,
"reporter": "spec",
"timeout": 5000
}
"timeout": 5000,
"node-option": [
"loader=ts-node/esm"
]
}
21 changes: 0 additions & 21 deletions bin/dev

This file was deleted.

4 changes: 2 additions & 2 deletions bin/dev.cmd
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off
set NODE_ENV=development
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.

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.
46 changes: 21 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,49 @@
"author": "Salesforce",
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/core": "^2.15.0",
"@oclif/core": "^3.9.2",
"@salesforce/core": "^5.3.17",
"@salesforce/kit": "^3.0.15",
"@salesforce/sf-plugins-core": "^3.1.22",
"@salesforce/sf-plugins-core": "^4.0.0",
"change-case": "^4.1.2",
"fast-glob": "^3.3.1",
"fast-xml-parser": "^4.3.2",
"inquirer": "^8.2.6",
"js2xmlparser": "^4.0.2",
"tslib": "^2"
"js2xmlparser": "^4.0.2"
},
"devDependencies": {
"@oclif/plugin-command-snapshot": "^4.0.14",
"@oclif/test": "^2.5.6",
"@salesforce/cli-plugins-testkit": "^4.4.10",
"@oclif/plugin-command-snapshot": "^5.0.1",
"@salesforce/cli-plugins-testkit": "^5.0.0",
"@salesforce/dev-scripts": "^6.0.3",
"@salesforce/plugin-command-reference": "^3.0.44",
"@salesforce/ts-sinon": "1.4.19",
"@swc/core": "^1.3.37",
"@types/inquirer": "^8.2.0",
"@types/shelljs": "^0.8.13",
"eslint-plugin-sf-plugin": "^1.16.14",
"oclif": "^3.17.1",
"shelljs": "^0.8.4",
"oclif": "^4.0.3",
"shx": "0.3.4",
"ts-node": "^10.9.1",
"typescript": "^5.2.2"
},
"config": {},
"engines": {
"node": ">=16.0.0"
"node": ">=18.0.0"
},
"files": [
"/lib",
"/messages",
"/oclif.manifest.json",
"/schemas"
"/schemas",
"/oclif.lock"
],
"homepage": "https://github.com/salesforcecli/plugin-sobject",
"keywords": [
"force",
"salesforce",
"sfdx",
"salesforcedx",
"sfdx-plugin",
"sf",
"sf-plugin",
"sf"
"sfdx",
"sfdx-plugin"
],
"license": "BSD-3-Clause",
"main": "lib/index.js",
"oclif": {
"commands": "./lib/commands",
"bin": "sf",
Expand All @@ -74,14 +67,15 @@
}
}
}
}
},
"flexibleTaxonomy": true
},
"repository": "salesforcecli/plugin-sobject",
"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",
Expand Down Expand Up @@ -173,7 +167,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 @@ -184,7 +178,7 @@
]
},
"test:deprecation-policy": {
"command": "\"./bin/dev\" snapshot:compare",
"command": "ts-node \"./bin/dev.js\" snapshot:compare",
"files": [
"src/**/*.ts"
],
Expand All @@ -194,12 +188,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"
}
15 changes: 8 additions & 7 deletions src/commands/schema/generate/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@
* 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 * as fs from 'node:fs';
import * as path from 'node:path';
import fs from 'node:fs';
import path, {dirname} from 'node:path';
import { fileURLToPath } from 'node:url';
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import { AnyJson } from '@salesforce/ts-types';
import { CustomField } from 'jsforce/api/metadata';
import { convertJsonToXml } from '../../../shared/convert';
import { convertJsonToXml } from '../../../shared/convert.js';
import {
descriptionPrompt,
apiNamePrompt,
objectPrompt,
integerValidation,
picklistPrompts,
} from '../../../shared/prompts/prompts';
import { relationshipFieldPrompts } from '../../../shared/prompts/relationshipField';
import { isObjectsFolder, labelValidation } from '../../../shared/flags';
} from '../../../shared/prompts/prompts.js';
import { relationshipFieldPrompts } from '../../../shared/prompts/relationshipField.js';
import { isObjectsFolder, labelValidation } from '../../../shared/flags.js';

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

const MAX_LONG_TEXT_LENGTH = 131072;
Expand Down
12 changes: 7 additions & 5 deletions src/commands/schema/generate/platformevent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
* 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 } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import { AnyJson } from '@salesforce/ts-types';
import { apiNamePrompt, descriptionPrompt, directoryPrompt, pluralPrompt } from '../../../shared/prompts/prompts';
import { writeObjectFile } from '../../../shared/fs';
import { SaveablePlatformEvent } from '../../../shared/types';
import { labelValidation } from '../../../shared/flags';
import { apiNamePrompt, descriptionPrompt, directoryPrompt, pluralPrompt } from '../../../shared/prompts/prompts.js';
import { writeObjectFile } from '../../../shared/fs.js';
import { SaveablePlatformEvent } from '../../../shared/types.js';
import { labelValidation } from '../../../shared/flags.js';

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

export type PlatformEventGenerateResult = {
Expand Down
11 changes: 6 additions & 5 deletions src/commands/schema/generate/sobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { dirname } from 'node:path';
import {fileURLToPath} from 'node:url';
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import { AnyJson } from '@salesforce/ts-types';
Expand All @@ -15,12 +16,12 @@ import {
pluralPrompt,
apiNamePrompt,
namePrompts,
} from '../../../shared/prompts/prompts';
import { writeObjectFile } from '../../../shared/fs';
import { SaveableCustomObject, NameFieldResponse } from '../../../shared/types';
import { labelValidation } from '../../../shared/flags';
} from '../../../shared/prompts/prompts.js';
import { writeObjectFile } from '../../../shared/fs.js';
import { SaveableCustomObject, NameFieldResponse } from '../../../shared/types.js';
import { labelValidation } from '../../../shared/flags.js';

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

export type CustomObjectGenerateResult = {
Expand Down
11 changes: 6 additions & 5 deletions src/commands/schema/generate/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import * as fs from 'node:fs';
import * as path from 'node:path';
import fs from 'node:fs';
import path, {dirname} from 'node:path';
import {fileURLToPath} from 'node:url';
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import { CustomTab } from 'jsforce/api/metadata';
import { isTabsFolder } from '../../../shared/flags';
import { convertJsonToXml } from '../../../shared/convert';
import { isTabsFolder } from '../../../shared/flags.js';
import { convertJsonToXml } from '../../../shared/convert.js';

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

export type GenerateTabResult = {
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/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import * as jsToXml from 'js2xmlparser';
import { XMLParser } from 'fast-xml-parser';
import { IOptions } from 'js2xmlparser/lib/options';
import { IOptions } from 'js2xmlparser/lib/options.js';
import { CustomObject, CustomField } from 'jsforce/api/metadata';
import { JsonMap } from '@salesforce/ts-types';

Expand Down
6 changes: 4 additions & 2 deletions src/shared/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { sep, resolve } from 'node:path';
import {sep, resolve, dirname} from 'node:path';
import { fileURLToPath } from 'node:url';
import { Messages, SfError } from '@salesforce/core';

Messages.importMessagesDirectory(__dirname);

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

// eslint-disable-next-line @typescript-eslint/require-await
Expand Down
10 changes: 5 additions & 5 deletions src/shared/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
* 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 * as path from 'node:path';
import * as fs from 'node:fs';
import * as fg from 'fast-glob';
import path from 'node:path';
import fs from 'node:fs';
import fg from 'fast-glob';
import { CustomObject } from 'jsforce/api/metadata';
import { convertJsonToXml, parseXml } from './convert';
import { SaveableCustomObject, SaveablePlatformEvent } from './types';
import { convertJsonToXml, parseXml } from './convert.js';
import { SaveableCustomObject, SaveablePlatformEvent } from './types.js';

const getObjectXmlByPathAsJson = async (objectFilePath: string): Promise<CustomObject> => {
const xml = await fs.promises.readFile(objectFilePath, 'utf8');
Expand Down
Loading

0 comments on commit aa4f41b

Please sign in to comment.