Skip to content

Commit

Permalink
Merge pull request #192 from salesforcecli/sm/noun-first
Browse files Browse the repository at this point in the history
fix: align with latest naming style
  • Loading branch information
iowillhoit authored Jan 25, 2023
2 parents 25ae73c + 6bd8a3e commit fb609bc
Show file tree
Hide file tree
Showing 17 changed files with 490 additions and 469 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ docs
package.json.bak.

# -- CLEAN ALL
*.tsbuildinfo
.eslintcache
.wireit
node_modules

# --
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2022, Salesforce.com, Inc.
Copyright (c) 2023, Salesforce.com, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Expand Down
16 changes: 8 additions & 8 deletions command-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
[
{
"command": "generate:metadata:field",
"command": "schema:generate:field",
"plugin": "@salesforce/plugin-sobject",
"flags": ["label", "object"],
"alias": []
"alias": ["generate:metadata:field"]
},
{
"command": "generate:metadata:platformevent",
"command": "schema:generate:platformevent",
"plugin": "@salesforce/plugin-sobject",
"flags": ["label"],
"alias": []
"alias": ["generate:metadata:platformevent"]
},
{
"command": "generate:metadata:sobject",
"command": "schema:generate:sobject",
"plugin": "@salesforce/plugin-sobject",
"flags": ["label", "use-default-features"],
"alias": []
"alias": ["generate:metadata:sobject"]
},
{
"command": "generate:metadata:tab",
"command": "schema:generate:tab",
"plugin": "@salesforce/plugin-sobject",
"flags": ["directory", "icon", "json", "object"],
"alias": []
"alias": ["generate:metadata:tab"]
}
]
130 changes: 111 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
"@oclif/test": "^2.2.20",
"@salesforce/cli-plugins-testkit": "^3.2.12",
"@salesforce/dev-config": "^3.1.0",
"@salesforce/dev-scripts": "^3.1.0",
"@salesforce/dev-scripts": "^4.0.0-beta.8",
"@salesforce/plugin-command-reference": "^2.2.8",
"@salesforce/prettier-config": "^0.0.2",
"@salesforce/ts-sinon": "1.4.3",
"@swc/core": "^1.3.24",
"@types/inquirer": "^8.2.0",
"@types/shelljs": "^0.8.11",
"@typescript-eslint/eslint-plugin": "^5.44.0",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.47.1",
"chai": "^4.3.7",
"eslint": "^8.32.0",
Expand All @@ -39,7 +39,7 @@
"eslint-plugin-header": "^3.0.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jsdoc": "^39.6.4",
"eslint-plugin-sf-plugin": "^1.6.2",
"eslint-plugin-sf-plugin": "^1.7.0",
"husky": "^7.0.4",
"mocha": "^9.2.2",
"nyc": "^15.1.0",
Expand All @@ -50,7 +50,8 @@
"shx": "0.3.4",
"sinon": "10.0.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.4"
"typescript": "^4.9.4",
"wireit": "^0.9.3"
},
"config": {},
"engines": {
Expand Down Expand Up @@ -84,39 +85,130 @@
"@salesforce/plugin-command-reference"
],
"topics": {
"generate": {
"description": "Commands to generate a project, create a function, and more.",
"schema": {
"external": true,
"subtopics": {
"metadata": {
"description": "Generate metadata files for various Salesforce metadata types."
"generate": {
"description": "Generate metadata files for various Salesforce database schema."
}
}
}
}
},
"repository": "salesforcecli/plugin-sobject",
"scripts": {
"build": "sf-build",
"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",
"compile": "sf-compile",
"compile": "wireit",
"docs": "sf-docs",
"format": "sf-format",
"lint": "sf-lint",
"format": "wireit",
"lint": "wireit",
"postpack": "shx rm -f oclif.manifest.json",
"posttest": "yarn lint && yarn test:deprecation-policy && yarn test:json-schema && yarn test:command-reference",
"prepack": "sf-prepack",
"prepare": "sf-install",
"pretest": "sf-compile-test",
"test": "sf-test",
"test:command-reference": "./bin/dev commandreference:generate --erroronwarnings",
"test:deprecation-policy": "./bin/dev snapshot:compare",
"test:json-schema": "./bin/dev schema:compare",
"test": "wireit",
"test:command-reference": "wireit",
"test:compile": "wireit",
"test:deprecation-policy": "wireit",
"test:json-schema": "wireit",
"test:nuts": "nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel",
"test:only": "wireit",
"version": "oclif readme"
},
"publishConfig": {
"access": "public"
},
"wireit": {
"build": {
"dependencies": [
"compile",
"lint"
]
},
"compile": {
"command": "tsc -p . --pretty --incremental",
"files": [
"src/**/*.ts",
"tsconfig.json",
"messages/**"
],
"output": [
"lib/**",
"*.tsbuildinfo"
],
"clean": "if-file-deleted"
},
"format": {
"command": "prettier --write \"+(src|test|schemas)/**/*.+(ts|js|json)|command-snapshot.json\""
},
"lint": {
"command": "eslint --color --cache --cache-location .eslintcache",
"files": [
"src/**/*.ts",
"test/**/*.ts",
".eslintignore",
".eslintrc.js"
],
"output": []
},
"test:compile": {
"command": "tsc -p \"./test\" --pretty",
"files": [
"test/**/*.ts",
"tsconfig.json",
"test/tsconfig.json"
],
"output": []
},
"test": {
"dependencies": [
"test:compile",
"test:only",
"test:command-reference",
"test:deprecation-policy",
"lint",
"test:json-schema"
]
},
"test:only": {
"command": "nyc mocha \"test/**/*.test.ts\"",
"files": [
"test/**/*.ts",
"src/**/*.ts",
"tsconfig.json",
"test/tsconfig.json"
],
"output": []
},
"test:command-reference": {
"command": "\"./bin/dev\" commandreference:generate --erroronwarnings",
"files": [
"src/**/*.ts",
"messages/**"
],
"output": [
"tmp/root"
]
},
"test:deprecation-policy": {
"command": "\"./bin/dev\" snapshot:compare",
"files": [
"src/**/*.ts"
],
"output": [],
"dependencies": [
"compile"
]
},
"test:json-schema": {
"command": "\"./bin/dev\" schema:compare",
"files": [
"src/**/*.ts",
"schemas"
],
"output": []
}
}
}
}
File renamed without changes.
47 changes: 47 additions & 0 deletions schemas/schema-generate-platformevent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/PlatformEventGenerateResult",
"definitions": {
"PlatformEventGenerateResult": {
"type": "object",
"properties": {
"object": {
"$ref": "#/definitions/SaveablePlatformEvent"
},
"path": {
"type": "string"
}
},
"required": ["object", "path"],
"additionalProperties": false
},
"SaveablePlatformEvent": {
"type": "object",
"properties": {
"fullName": {
"type": ["string", "null"]
},
"label": {
"type": ["string", "null"]
},
"deploymentStatus": {
"type": ["string", "null"]
},
"description": {
"type": ["string", "null"]
},
"pluralLabel": {
"type": ["string", "null"]
},
"eventType": {
"type": ["string", "null"]
},
"publishBehavior": {
"type": ["string", "null"]
}
},
"additionalProperties": false,
"description": "There are a lot of properties that we don't, and some that jsforce thinks are mandatory that aren't. Many apply to the various sub-species (mdt, external, events)\n\nThis type represents a PlatformEvent that can deploy."
}
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ export default class FieldGenerate extends SfCommand<FieldGenerateResult> {
public static readonly requiresProject = true;
public static enableJsonFlag = false;
public static state = 'beta';
public static readonly aliases = ['generate:metadata:field'];
public static readonly deprecateAliases = true;

public static flags = {
public static readonly flags = {
label: Flags.string({
char: 'l',
summary: messages.getMessage('flags.label.summary'),
Expand Down Expand Up @@ -192,10 +194,11 @@ export default class FieldGenerate extends SfCommand<FieldGenerateResult> {
{
type: 'number',
message: messages.getMessage('prompts.precision'),
validate: (n: number, answers: Response) => integerValidation(n, 1, 18 - answers.scale),
validate: (n: number, answers: Response) =>
answers.scale ? integerValidation(n, 1, 18 - answers.scale) : undefined,
name: 'precision',
when: (answers: Response) => ['Number', 'Currency'].includes(answers.type),
default: (answers: Response) => 18 - answers.scale,
default: (answers: Response) => (answers.scale ? 18 - answers.scale : undefined),
},
// non-fieldtype-specific questions
descriptionPrompt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ export type PlatformEventGenerateResult = {
path: string;
};

export default class ObjectGenerate extends SfCommand<PlatformEventGenerateResult> {
export default class PlatformEventGenerate extends SfCommand<PlatformEventGenerateResult> {
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly examples = messages.getMessages('examples');
public static readonly requiresProject = true;
public static enableJsonFlag = false;
public static state = 'beta';

public static flags = {
public static readonly aliases = ['generate:metadata:platformevent'];
public static readonly deprecateAliases = true;
public static readonly flags = {
label: Flags.string({
char: 'l',
summary: messages.getMessage('flags.label.summary'),
Expand All @@ -45,7 +46,7 @@ export default class ObjectGenerate extends SfCommand<PlatformEventGenerateResul
};

public async run(): Promise<PlatformEventGenerateResult> {
const { flags } = await this.parse(ObjectGenerate);
const { flags } = await this.parse(PlatformEventGenerate);

const responses = await this.prompt<SaveablePlatformEvent & { directory: string }>([
await directoryPrompt(this.project.getPackageDirectories()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ export default class ObjectGenerate extends SfCommand<CustomObjectGenerateResult
public static readonly requiresProject = true;
public static enableJsonFlag = false;
public static state = 'beta';

public static flags = {
public static readonly aliases = ['generate:metadata:sobject'];
public static readonly deprecateAliases = true;
public static readonly flags = {
label: Flags.string({
char: 'l',
summary: messages.getMessage('flags.label.summary'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ export type GenerateTabResult = {
};

export default class GenerateTab extends SfCommand<GenerateTabResult> {
public static summary = messages.getMessage('summary');
public static description = messages.getMessage('description');
public static examples = messages.getMessages('examples');
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly examples = messages.getMessages('examples');
public static readonly requiresProject = true;
public static state = 'beta';
public static readonly aliases = ['generate:metadata:tab'];
public static readonly deprecateAliases = true;

public static flags = {
public static readonly flags = {
object: Flags.string({
summary: messages.getMessage('flags.object.summary'),
description: messages.getMessage('flags.object.description'),
Expand Down
1 change: 1 addition & 0 deletions src/shared/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const writeObjectFile = async (
objectDirectory: string,
object: SaveablePlatformEvent | SaveableCustomObject
): Promise<string> => {
if (!object.fullName) throw new Error('object.fullName is required to write an object file');
await fs.promises.mkdir(path.join(objectDirectory, object.fullName), { recursive: true });
const targetFile = path.join(objectDirectory, object.fullName, `${object.fullName}.object-meta.xml`);
await fs.promises.writeFile(targetFile, convertJsonToXml({ json: object, type: 'CustomObject' }));
Expand Down
2 changes: 1 addition & 1 deletion src/shared/prompts/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const namePrompts = (label: string): Array<Question | ListQuestion> => [
},
{
type: 'input',
when: (answers: { nameFieldType: 'AutoNumber' | 'Text' }) => answers.nameFieldType === 'AutoNumber',
when: (answers) => answers.nameFieldType === 'AutoNumber',
message: messages.getMessage('nameFieldPrompts.autoNumberFormat'),
name: 'autoNumberFormat',
default: `${label}-{0}`,
Expand Down
Loading

0 comments on commit fb609bc

Please sign in to comment.