-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathcreate.ts
49 lines (42 loc) · 1.62 KB
/
create.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { flags, SfdxCommand } from '@salesforce/command';
import { Messages } from '@salesforce/core';
import { AnyJson } from '@salesforce/ts-types';
import * as jsonfile from 'jsonfile';
import { join } from 'path';
import * as recursive from 'recursive-readdir';
// Initialize Messages with the current plugin directory
Messages.importMessagesDirectory(__dirname);
// Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core,
// or any library that is using the messages framework can also be loaded this way.
const messages = Messages.loadMessages('sfdx-waw-plugin', 'waw');
export default class ConnectedAppCreate extends SfdxCommand {
public static description = messages.getMessage('source.create.description');
public static examples = [];
public static readonly flagsConfig = {
path: flags.string({
char: 'p',
description: messages.getMessage('source.create.flags.path'),
required: true
})
};
protected static requiresProject = true;
public async run(): Promise<AnyJson> {
const dir = this.flags.path;
const filePathAndName = join('.', 'sfdx-oss-manifest.json');
const json = {
sfdxSource: true,
version : '1.0.0',
files: []
};
await new Promise((resolve, reject) => {
recursive(dir, (err, files) => {
if (err) { reject(err); }
json.files.push(files);
jsonfile.writeFileSync(filePathAndName, json, { spaces: 2 });
resolve(files);
});
});
this.ux.log(`Created file ${filePathAndName}. Be sure to remove files you don't want to include.`);
return { filePathAndName, json };
}
}