bulkyard 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
/** Return type for the `bulkyard init` command. */
|
|
3
|
+
export type InitCommandResult = {
|
|
4
|
+
outputFile: string;
|
|
5
|
+
};
|
|
6
|
+
export default class Init extends SfCommand<InitCommandResult> {
|
|
7
|
+
static readonly summary: string;
|
|
8
|
+
static readonly description: string;
|
|
9
|
+
static readonly examples: string[];
|
|
10
|
+
static readonly flags: {
|
|
11
|
+
'output-file': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<InitCommandResult>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { existsSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
3
|
+
import { Messages, SfError } from '@salesforce/core';
|
|
4
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
5
|
+
const messages = Messages.loadMessages('bulkyard', 'bulkyard.init');
|
|
6
|
+
const TEMPLATE = `# bulkyard config file
|
|
7
|
+
# See: https://github.com/jessegarrido/bulkyard
|
|
8
|
+
|
|
9
|
+
# Path to the SQLite database file used for extract and load operations.
|
|
10
|
+
database: bulkyard.db
|
|
11
|
+
|
|
12
|
+
# List of Salesforce objects to process.
|
|
13
|
+
objects:
|
|
14
|
+
# --- Extract example ---
|
|
15
|
+
# Extracts Account records into the "Account" table in the database.
|
|
16
|
+
- object: Account
|
|
17
|
+
query: SELECT Id, Name, Industry FROM Account
|
|
18
|
+
|
|
19
|
+
# --- Load example (commented out) ---
|
|
20
|
+
# Upserts Contact records from the "Contact" table back into Salesforce.
|
|
21
|
+
# - object: Contact
|
|
22
|
+
# operation: upsert
|
|
23
|
+
# externalIdField: Id
|
|
24
|
+
|
|
25
|
+
# Each object entry supports the following fields:
|
|
26
|
+
# object (required) Salesforce object API name (e.g. Account, Contact)
|
|
27
|
+
# query (extract) SOQL query to execute
|
|
28
|
+
# operation (load) Bulk API operation: insert, update, upsert, or delete
|
|
29
|
+
# externalIdField (load) External ID field, required for upsert
|
|
30
|
+
# table (optional) SQLite table name override (defaults to the object name)
|
|
31
|
+
`;
|
|
32
|
+
export default class Init extends SfCommand {
|
|
33
|
+
static summary = messages.getMessage('summary');
|
|
34
|
+
static description = messages.getMessage('description');
|
|
35
|
+
static examples = messages.getMessages('examples');
|
|
36
|
+
static flags = {
|
|
37
|
+
'output-file': Flags.string({
|
|
38
|
+
char: 'o',
|
|
39
|
+
summary: messages.getMessage('flags.output-file.summary'),
|
|
40
|
+
default: 'bulkyard.config.yml',
|
|
41
|
+
}),
|
|
42
|
+
force: Flags.boolean({
|
|
43
|
+
char: 'f',
|
|
44
|
+
summary: messages.getMessage('flags.force.summary'),
|
|
45
|
+
default: false,
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
async run() {
|
|
49
|
+
const { flags } = await this.parse(Init);
|
|
50
|
+
const outputFile = flags['output-file'];
|
|
51
|
+
if (existsSync(outputFile) && !flags.force) {
|
|
52
|
+
throw new SfError(messages.getMessage('error.alreadyExists', [outputFile]), 'AlreadyExistsError', [
|
|
53
|
+
'Use --force to overwrite the existing file.',
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
writeFileSync(outputFile, TEMPLATE, 'utf8');
|
|
57
|
+
this.log(messages.getMessage('info.created', [outputFile]));
|
|
58
|
+
return { outputFile };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/bulky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C;QAExC,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YAC3C,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,oBAAoB,EAAE;gBAChG,6CAA6C;aAC9C,CAAC,CAAC;QACL,CAAC;QAED,aAAa,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAE5D,OAAO,EAAE,UAAU,EAAE,CAAC;IACxB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Generate an annotated bulkyard YAML config file.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Scaffolds a starter config file with commented examples for both extract and load operations. The generated file includes an active Account extract example and a commented-out Contact load example, with annotations explaining every field.
|
|
8
|
+
|
|
9
|
+
# examples
|
|
10
|
+
|
|
11
|
+
- Generate a default bulkyard.config.yml config file:
|
|
12
|
+
|
|
13
|
+
<%= config.bin %> <%= command.id %>
|
|
14
|
+
|
|
15
|
+
- Generate a config file at a custom path:
|
|
16
|
+
|
|
17
|
+
<%= config.bin %> <%= command.id %> --output-file my-config.yml
|
|
18
|
+
|
|
19
|
+
- Overwrite an existing config file:
|
|
20
|
+
|
|
21
|
+
<%= config.bin %> <%= command.id %> --force
|
|
22
|
+
|
|
23
|
+
# flags.output-file.summary
|
|
24
|
+
|
|
25
|
+
Path to write the generated config file.
|
|
26
|
+
|
|
27
|
+
# flags.force.summary
|
|
28
|
+
|
|
29
|
+
Overwrite the output file if it already exists.
|
|
30
|
+
|
|
31
|
+
# info.created
|
|
32
|
+
|
|
33
|
+
Created config file: %s
|
|
34
|
+
|
|
35
|
+
# error.alreadyExists
|
|
36
|
+
|
|
37
|
+
File already exists: %s. Use --force to overwrite.
|
package/oclif.manifest.json
CHANGED
|
@@ -115,6 +115,70 @@
|
|
|
115
115
|
"extract:bulkyard"
|
|
116
116
|
]
|
|
117
117
|
},
|
|
118
|
+
"bulkyard:init": {
|
|
119
|
+
"aliases": [],
|
|
120
|
+
"args": {},
|
|
121
|
+
"description": "Scaffolds a starter config file with commented examples for both extract and load operations. The generated file includes an active Account extract example and a commented-out Contact load example, with annotations explaining every field.",
|
|
122
|
+
"examples": [
|
|
123
|
+
"Generate a default bulkyard.config.yml config file:\n<%= config.bin %> <%= command.id %>",
|
|
124
|
+
"Generate a config file at a custom path:\n<%= config.bin %> <%= command.id %> --output-file my-config.yml",
|
|
125
|
+
"Overwrite an existing config file:\n<%= config.bin %> <%= command.id %> --force"
|
|
126
|
+
],
|
|
127
|
+
"flags": {
|
|
128
|
+
"json": {
|
|
129
|
+
"description": "Format output as json.",
|
|
130
|
+
"helpGroup": "GLOBAL",
|
|
131
|
+
"name": "json",
|
|
132
|
+
"allowNo": false,
|
|
133
|
+
"type": "boolean"
|
|
134
|
+
},
|
|
135
|
+
"flags-dir": {
|
|
136
|
+
"helpGroup": "GLOBAL",
|
|
137
|
+
"name": "flags-dir",
|
|
138
|
+
"summary": "Import flag values from a directory.",
|
|
139
|
+
"hasDynamicHelp": false,
|
|
140
|
+
"multiple": false,
|
|
141
|
+
"type": "option"
|
|
142
|
+
},
|
|
143
|
+
"output-file": {
|
|
144
|
+
"char": "o",
|
|
145
|
+
"name": "output-file",
|
|
146
|
+
"summary": "Path to write the generated config file.",
|
|
147
|
+
"default": "bulkyard.config.yml",
|
|
148
|
+
"hasDynamicHelp": false,
|
|
149
|
+
"multiple": false,
|
|
150
|
+
"type": "option"
|
|
151
|
+
},
|
|
152
|
+
"force": {
|
|
153
|
+
"char": "f",
|
|
154
|
+
"name": "force",
|
|
155
|
+
"summary": "Overwrite the output file if it already exists.",
|
|
156
|
+
"allowNo": false,
|
|
157
|
+
"type": "boolean"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"hasDynamicHelp": false,
|
|
161
|
+
"hiddenAliases": [],
|
|
162
|
+
"id": "bulkyard:init",
|
|
163
|
+
"pluginAlias": "bulkyard",
|
|
164
|
+
"pluginName": "bulkyard",
|
|
165
|
+
"pluginType": "core",
|
|
166
|
+
"strict": true,
|
|
167
|
+
"summary": "Generate an annotated bulkyard YAML config file.",
|
|
168
|
+
"enableJsonFlag": true,
|
|
169
|
+
"isESM": true,
|
|
170
|
+
"relativePath": [
|
|
171
|
+
"lib",
|
|
172
|
+
"commands",
|
|
173
|
+
"bulkyard",
|
|
174
|
+
"init.js"
|
|
175
|
+
],
|
|
176
|
+
"aliasPermutations": [],
|
|
177
|
+
"permutations": [
|
|
178
|
+
"bulkyard:init",
|
|
179
|
+
"init:bulkyard"
|
|
180
|
+
]
|
|
181
|
+
},
|
|
118
182
|
"bulkyard:load": {
|
|
119
183
|
"aliases": [],
|
|
120
184
|
"args": {},
|
|
@@ -248,5 +312,5 @@
|
|
|
248
312
|
]
|
|
249
313
|
}
|
|
250
314
|
},
|
|
251
|
-
"version": "1.
|
|
315
|
+
"version": "1.2.0"
|
|
252
316
|
}
|
package/package.json
CHANGED