create-powerapps-project 0.28.0 → 0.28.2
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.
- package/lib/index.js +27 -27
- package/lib/nuget.js +41 -41
- package/lib/packageManager.js +22 -22
- package/lib/plopActions.js +102 -102
- package/lib/plopfile.js +448 -436
- package/package.json +4 -1
- package/plop-templates/assembly/.editorconfig +131 -131
- package/plop-templates/assembly/builderSettings.json +17 -17
- package/plop-templates/webresource/.eslintignore +11 -11
- package/plop-templates/webresource/.prettierrc.json +4 -4
package/lib/plopfile.js
CHANGED
|
@@ -1,436 +1,448 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const path_1 = __importDefault(require("path"));
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const nuget_1 = require("./nuget");
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
10
|
-
const version = require('../package').version;
|
|
11
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
12
|
-
exports.default = (plop) => {
|
|
13
|
-
plop.setWelcomeMessage(`Creating new Dataverse project using create-powerapps-project v${version}. Please choose type of project to create.`);
|
|
14
|
-
plop.load('./plopActions');
|
|
15
|
-
const packageQuestion = {
|
|
16
|
-
type: 'list',
|
|
17
|
-
name: 'package',
|
|
18
|
-
message: 'package manager (ensure selected option is installed)',
|
|
19
|
-
choices: [
|
|
20
|
-
{ name: 'npm', value: 'npm' },
|
|
21
|
-
{ name: 'pnpm', value: 'pnpm' },
|
|
22
|
-
{ name: 'yarn', value: 'yarn' }
|
|
23
|
-
],
|
|
24
|
-
default: 'npm'
|
|
25
|
-
};
|
|
26
|
-
const sharedQuestions = [
|
|
27
|
-
{
|
|
28
|
-
type: 'input',
|
|
29
|
-
name: 'server',
|
|
30
|
-
message: 'enter dataverse url (https://org.crm.dynamics.com):',
|
|
31
|
-
validate: (answer) => {
|
|
32
|
-
try {
|
|
33
|
-
const url = new URL(answer);
|
|
34
|
-
if (url.protocol !== 'https:') {
|
|
35
|
-
return 'server should begin with https';
|
|
36
|
-
}
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
catch (ex) {
|
|
40
|
-
return 'enter a valid URL';
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
type: 'input',
|
|
46
|
-
name: 'tenant',
|
|
47
|
-
message: 'enter azure ad tenant (org.onmicrosoft.com):',
|
|
48
|
-
default: 'common'
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
type: 'input',
|
|
52
|
-
name: 'solution',
|
|
53
|
-
message: 'dataverse solution unique name:'
|
|
54
|
-
}
|
|
55
|
-
];
|
|
56
|
-
plop.setGenerator('assembly', {
|
|
57
|
-
description: 'generate dataverse plugin or workflow activity project',
|
|
58
|
-
prompts: [
|
|
59
|
-
{
|
|
60
|
-
type: 'confirm',
|
|
61
|
-
name: 'pluginPackage',
|
|
62
|
-
message: 'use plugin package (preview)?'
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
type: 'input',
|
|
66
|
-
name: 'prefix',
|
|
67
|
-
message: 'publisher prefix (no underscore):',
|
|
68
|
-
validate: (answer) => {
|
|
69
|
-
if (answer.slice(-1) === '_') {
|
|
70
|
-
return 'enter publisher prefix without the underscore';
|
|
71
|
-
}
|
|
72
|
-
return true;
|
|
73
|
-
},
|
|
74
|
-
when: (answers) => answers.pluginPackage
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
type: 'input',
|
|
78
|
-
name: 'author',
|
|
79
|
-
message: 'package author:',
|
|
80
|
-
when: (answers) => answers.pluginPackage
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
type: 'input',
|
|
84
|
-
name: 'company',
|
|
85
|
-
message: 'package company:',
|
|
86
|
-
when: (answers) => answers.pluginPackage
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
type: 'list',
|
|
90
|
-
name: 'sdkVersion',
|
|
91
|
-
message: (answers) => {
|
|
92
|
-
const crmPackage = answers.pluginPackage ? 'Microsoft.CrmSdk.CoreAssemblies' : 'Microsoft.CrmSdk.Workflow';
|
|
93
|
-
return `select ${crmPackage} version`;
|
|
94
|
-
},
|
|
95
|
-
choices: async (answers) => {
|
|
96
|
-
const crmPackage = answers.pluginPackage ? 'Microsoft.CrmSdk.CoreAssemblies' : 'Microsoft.CrmSdk.Workflow';
|
|
97
|
-
const versions = await (0, nuget_1.getNugetPackageVersions)(crmPackage);
|
|
98
|
-
return versions;
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
type: 'input',
|
|
103
|
-
name: 'name',
|
|
104
|
-
message: 'default C# namespace (Company.Crm.Plugins):',
|
|
105
|
-
validate: (answer) => {
|
|
106
|
-
const validNamespace = answer.replace(/[^a-zA-Z.]+/g, '');
|
|
107
|
-
if (validNamespace !== answer) {
|
|
108
|
-
return 'namespace must contain only alpha characters and periods';
|
|
109
|
-
}
|
|
110
|
-
const namespace = answer.split('.');
|
|
111
|
-
for (const item of namespace) {
|
|
112
|
-
const title = plop.renderString('{{pascalCase name}}', { name: item });
|
|
113
|
-
if (title !== item) {
|
|
114
|
-
return `enter namespace using PascalCase`;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
type: 'list',
|
|
122
|
-
name: 'isolation',
|
|
123
|
-
message: 'select isolation mode',
|
|
124
|
-
default: 2,
|
|
125
|
-
choices: [
|
|
126
|
-
{
|
|
127
|
-
name: 'sandbox',
|
|
128
|
-
value: 2
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
name: 'none',
|
|
132
|
-
value: 1
|
|
133
|
-
}
|
|
134
|
-
]
|
|
135
|
-
},
|
|
136
|
-
packageQuestion,
|
|
137
|
-
...sharedQuestions
|
|
138
|
-
],
|
|
139
|
-
actions: (data) => {
|
|
140
|
-
data.org = new URL(data.server).hostname.split('.')[0];
|
|
141
|
-
return [
|
|
142
|
-
async (answers) => {
|
|
143
|
-
const xrmVersions = await (0, nuget_1.getNugetPackageVersions)('JourneyTeam.Xrm');
|
|
144
|
-
answers.xrmVersion = xrmVersions.shift();
|
|
145
|
-
return `retrieved latest JourneyTeam.Xrm version ${answers.xrmVersion}`;
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
type: 'add',
|
|
149
|
-
templateFile: '../plop-templates/assembly/assembly.csproj.hbs',
|
|
150
|
-
path: path_1.default.resolve(process.cwd(), '{{name}}.csproj'),
|
|
151
|
-
skip: (answers) => {
|
|
152
|
-
if (answers.pluginPackage) {
|
|
153
|
-
return 'generating plugin package';
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
type: 'add',
|
|
162
|
-
templateFile: '../plop-templates/assembly/package.csproj.hbs',
|
|
163
|
-
path: path_1.default.resolve(process.cwd(), '{{name}}.csproj'),
|
|
164
|
-
skip: (answers) => {
|
|
165
|
-
if (!answers.pluginPackage) {
|
|
166
|
-
return 'generating regular assembly';
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
type: 'add',
|
|
175
|
-
templateFile: '../plop-templates/assembly/dataverse.config.json.hbs',
|
|
176
|
-
path: path_1.default.resolve(process.cwd(), 'dataverse.config.json'),
|
|
177
|
-
skip: (answers) => {
|
|
178
|
-
if (answers.pluginPackage) {
|
|
179
|
-
return 'generating plugin package';
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
type: 'add',
|
|
188
|
-
templateFile: '../plop-templates/assembly/dataverse.package.config.json.hbs',
|
|
189
|
-
path: path_1.default.resolve(process.cwd(), 'dataverse.config.json'),
|
|
190
|
-
skip: (answers) => {
|
|
191
|
-
if (!answers.pluginPackage) {
|
|
192
|
-
return 'generating regular assembly';
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
type: 'addMany',
|
|
201
|
-
templateFiles: [
|
|
202
|
-
'../plop-templates/assembly/package.json.hbs',
|
|
203
|
-
'../plop-templates/assembly/plopfile.js',
|
|
204
|
-
'../plop-templates/assembly/.gitignore',
|
|
205
|
-
'../plop-templates/assembly
|
|
206
|
-
'../plop-templates/assembly
|
|
207
|
-
'../plop-templates/assembly/.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
{ name: '
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
},
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
'
|
|
417
|
-
'
|
|
418
|
-
'@
|
|
419
|
-
'
|
|
420
|
-
'
|
|
421
|
-
'
|
|
422
|
-
'
|
|
423
|
-
'
|
|
424
|
-
'
|
|
425
|
-
'
|
|
426
|
-
'
|
|
427
|
-
'-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const nuget_1 = require("./nuget");
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
10
|
+
const version = require('../package').version;
|
|
11
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
12
|
+
exports.default = (plop) => {
|
|
13
|
+
plop.setWelcomeMessage(`Creating new Dataverse project using create-powerapps-project v${version}. Please choose type of project to create.`);
|
|
14
|
+
plop.load('./plopActions');
|
|
15
|
+
const packageQuestion = {
|
|
16
|
+
type: 'list',
|
|
17
|
+
name: 'package',
|
|
18
|
+
message: 'package manager (ensure selected option is installed)',
|
|
19
|
+
choices: [
|
|
20
|
+
{ name: 'npm', value: 'npm' },
|
|
21
|
+
{ name: 'pnpm', value: 'pnpm' },
|
|
22
|
+
{ name: 'yarn', value: 'yarn' }
|
|
23
|
+
],
|
|
24
|
+
default: 'npm'
|
|
25
|
+
};
|
|
26
|
+
const sharedQuestions = [
|
|
27
|
+
{
|
|
28
|
+
type: 'input',
|
|
29
|
+
name: 'server',
|
|
30
|
+
message: 'enter dataverse url (https://org.crm.dynamics.com):',
|
|
31
|
+
validate: (answer) => {
|
|
32
|
+
try {
|
|
33
|
+
const url = new URL(answer);
|
|
34
|
+
if (url.protocol !== 'https:') {
|
|
35
|
+
return 'server should begin with https';
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
catch (ex) {
|
|
40
|
+
return 'enter a valid URL';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'input',
|
|
46
|
+
name: 'tenant',
|
|
47
|
+
message: 'enter azure ad tenant (org.onmicrosoft.com):',
|
|
48
|
+
default: 'common'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'input',
|
|
52
|
+
name: 'solution',
|
|
53
|
+
message: 'dataverse solution unique name:'
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
plop.setGenerator('assembly', {
|
|
57
|
+
description: 'generate dataverse plugin or workflow activity project',
|
|
58
|
+
prompts: [
|
|
59
|
+
{
|
|
60
|
+
type: 'confirm',
|
|
61
|
+
name: 'pluginPackage',
|
|
62
|
+
message: 'use plugin package (preview)?'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: 'input',
|
|
66
|
+
name: 'prefix',
|
|
67
|
+
message: 'publisher prefix (no underscore):',
|
|
68
|
+
validate: (answer) => {
|
|
69
|
+
if (answer.slice(-1) === '_') {
|
|
70
|
+
return 'enter publisher prefix without the underscore';
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
},
|
|
74
|
+
when: (answers) => answers.pluginPackage
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: 'input',
|
|
78
|
+
name: 'author',
|
|
79
|
+
message: 'package author:',
|
|
80
|
+
when: (answers) => answers.pluginPackage
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'input',
|
|
84
|
+
name: 'company',
|
|
85
|
+
message: 'package company:',
|
|
86
|
+
when: (answers) => answers.pluginPackage
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: 'list',
|
|
90
|
+
name: 'sdkVersion',
|
|
91
|
+
message: (answers) => {
|
|
92
|
+
const crmPackage = answers.pluginPackage ? 'Microsoft.CrmSdk.CoreAssemblies' : 'Microsoft.CrmSdk.Workflow';
|
|
93
|
+
return `select ${crmPackage} version`;
|
|
94
|
+
},
|
|
95
|
+
choices: async (answers) => {
|
|
96
|
+
const crmPackage = answers.pluginPackage ? 'Microsoft.CrmSdk.CoreAssemblies' : 'Microsoft.CrmSdk.Workflow';
|
|
97
|
+
const versions = await (0, nuget_1.getNugetPackageVersions)(crmPackage);
|
|
98
|
+
return versions;
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
type: 'input',
|
|
103
|
+
name: 'name',
|
|
104
|
+
message: 'default C# namespace (Company.Crm.Plugins):',
|
|
105
|
+
validate: (answer) => {
|
|
106
|
+
const validNamespace = answer.replace(/[^a-zA-Z.]+/g, '');
|
|
107
|
+
if (validNamespace !== answer) {
|
|
108
|
+
return 'namespace must contain only alpha characters and periods';
|
|
109
|
+
}
|
|
110
|
+
const namespace = answer.split('.');
|
|
111
|
+
for (const item of namespace) {
|
|
112
|
+
const title = plop.renderString('{{pascalCase name}}', { name: item });
|
|
113
|
+
if (title !== item) {
|
|
114
|
+
return `enter namespace using PascalCase`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
type: 'list',
|
|
122
|
+
name: 'isolation',
|
|
123
|
+
message: 'select isolation mode',
|
|
124
|
+
default: 2,
|
|
125
|
+
choices: [
|
|
126
|
+
{
|
|
127
|
+
name: 'sandbox',
|
|
128
|
+
value: 2
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'none',
|
|
132
|
+
value: 1
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
packageQuestion,
|
|
137
|
+
...sharedQuestions
|
|
138
|
+
],
|
|
139
|
+
actions: (data) => {
|
|
140
|
+
data.org = new URL(data.server).hostname.split('.')[0];
|
|
141
|
+
return [
|
|
142
|
+
async (answers) => {
|
|
143
|
+
const xrmVersions = await (0, nuget_1.getNugetPackageVersions)('JourneyTeam.Xrm');
|
|
144
|
+
answers.xrmVersion = xrmVersions.shift();
|
|
145
|
+
return `retrieved latest JourneyTeam.Xrm version ${answers.xrmVersion}`;
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
type: 'add',
|
|
149
|
+
templateFile: '../plop-templates/assembly/assembly.csproj.hbs',
|
|
150
|
+
path: path_1.default.resolve(process.cwd(), '{{name}}.csproj'),
|
|
151
|
+
skip: (answers) => {
|
|
152
|
+
if (answers.pluginPackage) {
|
|
153
|
+
return 'generating plugin package';
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
type: 'add',
|
|
162
|
+
templateFile: '../plop-templates/assembly/package.csproj.hbs',
|
|
163
|
+
path: path_1.default.resolve(process.cwd(), '{{name}}.csproj'),
|
|
164
|
+
skip: (answers) => {
|
|
165
|
+
if (!answers.pluginPackage) {
|
|
166
|
+
return 'generating regular assembly';
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
type: 'add',
|
|
175
|
+
templateFile: '../plop-templates/assembly/dataverse.config.json.hbs',
|
|
176
|
+
path: path_1.default.resolve(process.cwd(), 'dataverse.config.json'),
|
|
177
|
+
skip: (answers) => {
|
|
178
|
+
if (answers.pluginPackage) {
|
|
179
|
+
return 'generating plugin package';
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
type: 'add',
|
|
188
|
+
templateFile: '../plop-templates/assembly/dataverse.package.config.json.hbs',
|
|
189
|
+
path: path_1.default.resolve(process.cwd(), 'dataverse.config.json'),
|
|
190
|
+
skip: (answers) => {
|
|
191
|
+
if (!answers.pluginPackage) {
|
|
192
|
+
return 'generating regular assembly';
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
type: 'addMany',
|
|
201
|
+
templateFiles: [
|
|
202
|
+
'../plop-templates/assembly/package.json.hbs',
|
|
203
|
+
'../plop-templates/assembly/plopfile.js',
|
|
204
|
+
'../plop-templates/assembly/.gitignore',
|
|
205
|
+
'../plop-templates/assembly/.gitattributes',
|
|
206
|
+
'../plop-templates/assembly/builderSettings.json',
|
|
207
|
+
'../plop-templates/assembly/.vscode/tasks.json.hbs',
|
|
208
|
+
'../plop-templates/assembly/.editorconfig'
|
|
209
|
+
],
|
|
210
|
+
base: '../plop-templates/assembly',
|
|
211
|
+
destination: process.cwd(),
|
|
212
|
+
force: true
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
type: 'addScript',
|
|
216
|
+
data: {
|
|
217
|
+
scriptKey: 'preinstall',
|
|
218
|
+
scriptValue: `npx only-allow ${data.package}`
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
type: 'signAssembly'
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
type: 'nugetRestore'
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
type: 'npmInstall',
|
|
229
|
+
data: {
|
|
230
|
+
packages: {
|
|
231
|
+
devDependencies: ['powerapps-project-assembly', 'dataverse-utils']
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
];
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
plop.setGenerator('pcf', {
|
|
239
|
+
description: 'generate dataverse pcf project',
|
|
240
|
+
prompts: [
|
|
241
|
+
{
|
|
242
|
+
type: 'list',
|
|
243
|
+
name: 'template',
|
|
244
|
+
message: 'template',
|
|
245
|
+
choices: [
|
|
246
|
+
{ name: 'field', value: 'field' },
|
|
247
|
+
{ name: 'dataset', value: 'dataset' }
|
|
248
|
+
]
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
type: 'input',
|
|
252
|
+
name: 'namespace',
|
|
253
|
+
message: 'namespace'
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
type: 'input',
|
|
257
|
+
name: 'name',
|
|
258
|
+
message: 'name'
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
type: 'input',
|
|
262
|
+
name: 'prefix',
|
|
263
|
+
message: 'publisher prefix'
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
type: 'confirm',
|
|
267
|
+
name: 'react',
|
|
268
|
+
message: 'use react?'
|
|
269
|
+
},
|
|
270
|
+
packageQuestion
|
|
271
|
+
],
|
|
272
|
+
actions: (data) => {
|
|
273
|
+
return [
|
|
274
|
+
{
|
|
275
|
+
type: 'runPcf'
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
type: 'add',
|
|
279
|
+
templateFile: '../plop-templates/pcf/tsconfig.json',
|
|
280
|
+
path: path_1.default.resolve(process.cwd(), 'tsconfig.json'),
|
|
281
|
+
force: true
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
type: 'add',
|
|
285
|
+
templateFile: '../plop-templates/pcf/plopfile.js',
|
|
286
|
+
path: path_1.default.resolve(process.cwd(), 'plopfile.js'),
|
|
287
|
+
force: true
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
type: 'add',
|
|
291
|
+
templateFile: '../plop-templates/pcf/.gitattributes',
|
|
292
|
+
path: path_1.default.resolve(process.cwd(), '.gitattributes'),
|
|
293
|
+
force: true
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
type: 'addMany',
|
|
297
|
+
templateFiles: [
|
|
298
|
+
'../plop-templates/pcf/App.tsx.hbs',
|
|
299
|
+
'../plop-templates/pcf/AppContext.tsx',
|
|
300
|
+
'../plop-templates/webresource/.gitattributes'
|
|
301
|
+
],
|
|
302
|
+
base: '../plop-templates/pcf',
|
|
303
|
+
destination: `${process.cwd()}/{{name}}`,
|
|
304
|
+
skip: (answers) => {
|
|
305
|
+
if (!answers.react) {
|
|
306
|
+
return 'react not included';
|
|
307
|
+
}
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
type: 'modify',
|
|
313
|
+
path: `${process.cwd()}/{{name}}/index.ts`,
|
|
314
|
+
pattern: 'import { HelloWorld, IHelloWorldProps } from "./HelloWorld";',
|
|
315
|
+
template: `import { App, IAppProps } from './App';`
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
type: 'modify',
|
|
319
|
+
path: `${process.cwd()}/{{name}}/index.ts`,
|
|
320
|
+
pattern: 'HelloWorld, props',
|
|
321
|
+
template: 'App, props'
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
type: 'modify',
|
|
325
|
+
path: `${process.cwd()}/{{name}}/index.ts`,
|
|
326
|
+
pattern: `const props: IHelloWorldProps = { name: 'Hello, World!' };`,
|
|
327
|
+
template: `const props: IAppProps = { context: context };`
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
type: 'addScript',
|
|
331
|
+
data: {
|
|
332
|
+
scriptKey: 'build:prod',
|
|
333
|
+
scriptValue: 'pcf-scripts build --buildMode production'
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
type: 'addScript',
|
|
338
|
+
data: {
|
|
339
|
+
scriptKey: 'push',
|
|
340
|
+
scriptValue: `pac pcf version --strategy manifest && pac pcf push -pp ${data.prefix}`
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
type: 'addScript',
|
|
345
|
+
data: {
|
|
346
|
+
scriptKey: 'preinstall',
|
|
347
|
+
scriptValue: `npx only-allow ${data.package}`
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
async (answers) => {
|
|
351
|
+
if (answers.react) {
|
|
352
|
+
await fs_1.default.promises.rm(path_1.default.resolve(process.cwd(), answers.name, 'HelloWorld.tsx'));
|
|
353
|
+
return 'removed HelloWorld component';
|
|
354
|
+
}
|
|
355
|
+
return 'react not included';
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
type: 'npmInstall'
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
type: 'npmInstall',
|
|
362
|
+
data: {
|
|
363
|
+
packages: {
|
|
364
|
+
devDependencies: ['powerapps-project-pcf', '@types/react@16', '@types/react-dom@16']
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
];
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
plop.setGenerator('webresource', {
|
|
372
|
+
description: 'generate dataverse web resource project',
|
|
373
|
+
prompts: [
|
|
374
|
+
{
|
|
375
|
+
type: 'input',
|
|
376
|
+
name: 'name',
|
|
377
|
+
message: 'project name',
|
|
378
|
+
default: path_1.default.basename(process.cwd())
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
type: 'input',
|
|
382
|
+
name: 'namespace',
|
|
383
|
+
message: 'namespace for form and ribbon scripts:'
|
|
384
|
+
},
|
|
385
|
+
packageQuestion,
|
|
386
|
+
...sharedQuestions
|
|
387
|
+
],
|
|
388
|
+
actions: (data) => {
|
|
389
|
+
return [
|
|
390
|
+
{
|
|
391
|
+
type: 'addMany',
|
|
392
|
+
templateFiles: [
|
|
393
|
+
'../plop-templates/webresource/*',
|
|
394
|
+
'../plop-templates/webresource/.*',
|
|
395
|
+
'../plop-templates/webresource/.gitignore',
|
|
396
|
+
'../plop-templates/webresource/.gitattributes',
|
|
397
|
+
'../plop-templates/webresource/.eslintignore',
|
|
398
|
+
'../plop-templates/webresource/.prettierignore'
|
|
399
|
+
],
|
|
400
|
+
base: '../plop-templates/webresource',
|
|
401
|
+
destination: process.cwd(),
|
|
402
|
+
force: true
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
type: 'addScript',
|
|
406
|
+
data: {
|
|
407
|
+
scriptKey: 'preinstall',
|
|
408
|
+
scriptValue: `npx only-allow ${data.package}`
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
type: 'npmInstall',
|
|
413
|
+
data: {
|
|
414
|
+
packages: {
|
|
415
|
+
devDependencies: [
|
|
416
|
+
'powerapps-project-webresource',
|
|
417
|
+
'dataverse-utils',
|
|
418
|
+
'@types/xrm',
|
|
419
|
+
'typescript',
|
|
420
|
+
'eslint',
|
|
421
|
+
'prettier',
|
|
422
|
+
'eslint-config-prettier',
|
|
423
|
+
'@typescript-eslint/eslint-plugin',
|
|
424
|
+
'@typescript-eslint/parser',
|
|
425
|
+
'webpack-event-plugin',
|
|
426
|
+
'clean-webpack-plugin',
|
|
427
|
+
'source-map-loader',
|
|
428
|
+
'babel-loader',
|
|
429
|
+
'ts-loader',
|
|
430
|
+
'@babel/core',
|
|
431
|
+
'@babel/preset-env',
|
|
432
|
+
'@babel/preset-typescript',
|
|
433
|
+
'xrm-mock',
|
|
434
|
+
'webpack',
|
|
435
|
+
'webpack-cli',
|
|
436
|
+
'cross-spawn',
|
|
437
|
+
'ts-node',
|
|
438
|
+
'@microsoft/eslint-plugin-power-apps',
|
|
439
|
+
'-D'
|
|
440
|
+
],
|
|
441
|
+
dependencies: ['core-js', 'regenerator-runtime', 'powerapps-common', 'dataverse-webapi']
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
];
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
};
|