create-powerapps-project 0.20.0 → 0.21.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.
- package/lib/packageManager.js +8 -38
- package/lib/plopfile.js +143 -92
- package/package.json +3 -4
- package/plop-templates/pcf/App.tsx.hbs +20 -0
- package/plop-templates/pcf/AppContext.ts +10 -0
- package/plop-templates/pcf/tsconfig.json +3 -2
- package/lib/getEnvInfo.js +0 -33
- package/plop-templates/pcf/App.tsx +0 -20
- package/plop-templates/pcf/index.ts.hbs +0 -70
package/lib/packageManager.js
CHANGED
|
@@ -1,55 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.install =
|
|
3
|
+
exports.install = void 0;
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
5
|
const child_process_1 = require("child_process");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const yarnInfo = (0, getEnvInfo_1.getEnvInfo)().Binaries.Yarn;
|
|
9
|
-
return yarnInfo && yarnInfo.path;
|
|
10
|
-
};
|
|
11
|
-
exports.getYarn = getYarn;
|
|
12
|
-
const getNpm = () => {
|
|
13
|
-
const npmInfo = (0, getEnvInfo_1.getEnvInfo)().Binaries.npm;
|
|
14
|
-
return npmInfo && npmInfo.path;
|
|
15
|
-
};
|
|
16
|
-
const install = (cwd, type) => {
|
|
17
|
-
const packages = getPackages(type);
|
|
18
|
-
if (process.env.JEST_WORKER_ID !== undefined) {
|
|
6
|
+
const install = (cwd, type, packageManager) => {
|
|
7
|
+
if (process.env.JEST_WORKER_ID != undefined) {
|
|
19
8
|
return;
|
|
20
9
|
}
|
|
21
|
-
if (
|
|
22
|
-
(0, child_process_1.spawnSync)(
|
|
23
|
-
if (packages.dependencies) {
|
|
24
|
-
(0, child_process_1.spawnSync)((0, exports.getYarn)(), ['add', ...packages.dependencies], { stdio: 'inherit', cwd });
|
|
25
|
-
}
|
|
10
|
+
if (type === 'pcf') {
|
|
11
|
+
(0, child_process_1.spawnSync)(packageManager, ['install'], { stdio: 'inherit', shell: true });
|
|
26
12
|
}
|
|
27
13
|
else {
|
|
28
|
-
|
|
14
|
+
const packages = getPackages(type);
|
|
15
|
+
(0, child_process_1.spawnSync)(packageManager, ['add', ...packages.devDependencies], { stdio: 'inherit', shell: true });
|
|
29
16
|
if (packages.dependencies) {
|
|
30
|
-
(0, child_process_1.spawnSync)(
|
|
17
|
+
(0, child_process_1.spawnSync)(packageManager, ['add', ...packages.dependencies], { stdio: 'inherit', shell: true });
|
|
31
18
|
}
|
|
32
19
|
}
|
|
33
20
|
};
|
|
34
21
|
exports.install = install;
|
|
35
22
|
function getPackages(type) {
|
|
36
|
-
if (type === 'pcf') {
|
|
37
|
-
return {
|
|
38
|
-
dependencies: [
|
|
39
|
-
'react@17.0.2',
|
|
40
|
-
'react-dom@17.0.2',
|
|
41
|
-
'@fluentui/react',
|
|
42
|
-
'@fluentui/font-icons-mdl2'
|
|
43
|
-
],
|
|
44
|
-
devDependencies: [
|
|
45
|
-
//`powerapps-project-${type}`,
|
|
46
|
-
'@types/react@17.0.39',
|
|
47
|
-
'@types/react-dom@17.0.11',
|
|
48
|
-
'@types/xrm',
|
|
49
|
-
'-D'
|
|
50
|
-
]
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
23
|
const packages = {
|
|
54
24
|
devDependencies: [
|
|
55
25
|
`powerapps-project-${type}`,
|
package/lib/plopfile.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -27,76 +31,22 @@ const child_process_1 = require("child_process");
|
|
|
27
31
|
const fs_1 = __importDefault(require("fs"));
|
|
28
32
|
const nuget = __importStar(require("./nuget"));
|
|
29
33
|
const pkg = __importStar(require("./packageManager"));
|
|
30
|
-
const getEnvInfo_1 = require("./getEnvInfo");
|
|
31
34
|
const didSucceed = (code) => `${code}` === '0';
|
|
32
35
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
33
36
|
exports.default = (plop) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
reject('failed to sign assembly');
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
sign.on('error', () => {
|
|
51
|
-
reject('failed to sign assembly');
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
plop.setActionType('runPcf', (answers) => {
|
|
56
|
-
const args = ['pcf', 'init', '-ns', answers.namespace, '-n', answers.name, '-t', answers.template];
|
|
57
|
-
/// Setting framework to React currently unsupported by PCF CLI
|
|
58
|
-
// if (answers.react) {
|
|
59
|
-
// args.push('-fw', 'react');
|
|
60
|
-
// }
|
|
61
|
-
if (process.env.JEST_WORKER_ID !== undefined) {
|
|
62
|
-
args.push('-npm', 'false');
|
|
63
|
-
}
|
|
64
|
-
return new Promise((resolve, reject) => {
|
|
65
|
-
const pac = (0, child_process_1.spawn)('pac', args, { stdio: 'inherit' });
|
|
66
|
-
pac.on('close', (code) => {
|
|
67
|
-
if (didSucceed(code)) {
|
|
68
|
-
resolve('pcf project created');
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
reject('Ensure the Power Platform CLI is installed. Command must be run from within VS Code if using the Power Platform Extension');
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
pac.on('error', () => {
|
|
75
|
-
reject('Ensure the Power Platform CLI is installed. Command must be run from within VS Code if using the Power Platform Extension');
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
plop.setActionType('addGenScript', async () => {
|
|
80
|
-
const packagePath = path_1.default.resolve(process.cwd(), 'package.json');
|
|
81
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
82
|
-
const packageJson = require(packagePath);
|
|
83
|
-
packageJson.scripts.gen = 'plop';
|
|
84
|
-
await fs_1.default.promises.writeFile(packagePath, JSON.stringify(packageJson, null, 4), 'utf8');
|
|
85
|
-
return 'added plop script to package.json';
|
|
86
|
-
});
|
|
87
|
-
plop.setActionType('nugetInstall', async (answers) => {
|
|
88
|
-
const xrmVersions = await nuget.getNugetPackageVersions('JourneyTeam.Xrm');
|
|
89
|
-
const xrmVersion = xrmVersions.shift();
|
|
90
|
-
nuget.install(answers.name, answers.sdkVersion, xrmVersion);
|
|
91
|
-
return 'installed nuget packages';
|
|
92
|
-
});
|
|
93
|
-
plop.setActionType('npmInstall', (answers) => {
|
|
94
|
-
if (answers.projectType) {
|
|
95
|
-
pkg.install(process.cwd(), answers.projectType);
|
|
96
|
-
}
|
|
97
|
-
return 'installed npm packages';
|
|
98
|
-
});
|
|
99
|
-
const connectionQuestions = [
|
|
37
|
+
plop.setWelcomeMessage('[DATAVERSE] Please choose type of project to create.');
|
|
38
|
+
const packageQuestion = {
|
|
39
|
+
type: 'list',
|
|
40
|
+
name: 'package',
|
|
41
|
+
message: 'package manager (ensure selected option is installed)',
|
|
42
|
+
choices: [
|
|
43
|
+
{ name: 'npm', value: 'npm' },
|
|
44
|
+
{ name: 'pnpm', value: 'pnpm' },
|
|
45
|
+
{ name: 'yarn', value: 'yarn' }
|
|
46
|
+
],
|
|
47
|
+
default: 'npm'
|
|
48
|
+
};
|
|
49
|
+
const sharedQuestions = [
|
|
100
50
|
{
|
|
101
51
|
type: 'input',
|
|
102
52
|
name: 'server',
|
|
@@ -114,6 +64,18 @@ exports.default = (plop) => {
|
|
|
114
64
|
message: 'dataverse solution unique name:'
|
|
115
65
|
}
|
|
116
66
|
];
|
|
67
|
+
plop.setActionType('addScript', async (answers) => {
|
|
68
|
+
const packagePath = path_1.default.resolve(process.cwd(), 'package.json');
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
70
|
+
const packageJson = require(packagePath);
|
|
71
|
+
packageJson.scripts[answers.scriptKey] = answers.scriptValue;
|
|
72
|
+
await fs_1.default.promises.writeFile(packagePath, JSON.stringify(packageJson, null, 4), 'utf8');
|
|
73
|
+
return `added ${answers.scriptKey} script to package.json`;
|
|
74
|
+
});
|
|
75
|
+
plop.setActionType('npmInstall', (answers) => {
|
|
76
|
+
pkg.install(process.cwd(), answers.projectType, answers.package);
|
|
77
|
+
return 'installed npm packages';
|
|
78
|
+
});
|
|
117
79
|
plop.setGenerator('assembly', {
|
|
118
80
|
description: 'generate dataverse assembly project',
|
|
119
81
|
prompts: [
|
|
@@ -129,7 +91,20 @@ exports.default = (plop) => {
|
|
|
129
91
|
{
|
|
130
92
|
type: 'input',
|
|
131
93
|
name: 'name',
|
|
132
|
-
message: 'default C# namespace (Company.Crm.Plugins):'
|
|
94
|
+
message: 'default C# namespace (Company.Crm.Plugins):',
|
|
95
|
+
validate: (name) => {
|
|
96
|
+
const namespace = name.split('.');
|
|
97
|
+
if (namespace.length !== 3) {
|
|
98
|
+
return `enter namespace using 'Company.Crm.Plugins' convention`;
|
|
99
|
+
}
|
|
100
|
+
for (const item of namespace) {
|
|
101
|
+
const title = plop.renderString('{{titleCase name}}', { name: item });
|
|
102
|
+
if (title !== item) {
|
|
103
|
+
return `enter namespace using pascal case (Company.Crm.Plugins)`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
133
108
|
},
|
|
134
109
|
{
|
|
135
110
|
type: 'list',
|
|
@@ -147,7 +122,8 @@ exports.default = (plop) => {
|
|
|
147
122
|
}
|
|
148
123
|
]
|
|
149
124
|
},
|
|
150
|
-
|
|
125
|
+
packageQuestion,
|
|
126
|
+
...sharedQuestions,
|
|
151
127
|
],
|
|
152
128
|
actions: [
|
|
153
129
|
{
|
|
@@ -170,11 +146,33 @@ exports.default = (plop) => {
|
|
|
170
146
|
destination: process.cwd(),
|
|
171
147
|
force: true
|
|
172
148
|
},
|
|
173
|
-
{
|
|
174
|
-
|
|
149
|
+
(answers) => {
|
|
150
|
+
const keyPath = path_1.default.resolve(process.cwd(), `${answers.name}.snk`);
|
|
151
|
+
return new Promise((resolve, reject) => {
|
|
152
|
+
if (process.env.JEST_WORKER_ID !== undefined) {
|
|
153
|
+
resolve('Testing so no need to sign');
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const sign = (0, child_process_1.spawn)(path_1.default.resolve(__dirname, '..', 'bin', 'sn.exe'), ['-q', '-k', keyPath], { stdio: 'inherit' });
|
|
157
|
+
sign.on('close', (code) => {
|
|
158
|
+
if (didSucceed(code)) {
|
|
159
|
+
resolve('signed assembly');
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
reject('failed to sign assembly');
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
sign.on('error', () => {
|
|
166
|
+
reject('failed to sign assembly');
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
});
|
|
175
170
|
},
|
|
176
|
-
{
|
|
177
|
-
|
|
171
|
+
async (answers) => {
|
|
172
|
+
const xrmVersions = await nuget.getNugetPackageVersions('JourneyTeam.Xrm');
|
|
173
|
+
const xrmVersion = xrmVersions.shift();
|
|
174
|
+
nuget.install(answers.name, answers.sdkVersion, xrmVersion);
|
|
175
|
+
return 'installed nuget packages';
|
|
178
176
|
},
|
|
179
177
|
{
|
|
180
178
|
type: 'npmInstall',
|
|
@@ -210,21 +208,51 @@ exports.default = (plop) => {
|
|
|
210
208
|
type: 'confirm',
|
|
211
209
|
name: 'react',
|
|
212
210
|
message: 'use react?'
|
|
213
|
-
}
|
|
211
|
+
},
|
|
212
|
+
packageQuestion
|
|
214
213
|
],
|
|
215
214
|
actions: [
|
|
215
|
+
(answers) => {
|
|
216
|
+
const args = ['pcf', 'init', '-ns', answers.namespace, '-n', answers.name, '-t', answers.template];
|
|
217
|
+
// Set framework to React if selected
|
|
218
|
+
if (answers.react) {
|
|
219
|
+
args.push('-fw', 'react');
|
|
220
|
+
}
|
|
221
|
+
if (process.env.JEST_WORKER_ID !== undefined || answers.package !== 'npm') {
|
|
222
|
+
args.push('-npm', 'false');
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
args.push('-npm', 'true');
|
|
226
|
+
}
|
|
227
|
+
return new Promise((resolve, reject) => {
|
|
228
|
+
const pac = (0, child_process_1.spawn)('pac', args, { stdio: 'inherit' });
|
|
229
|
+
pac.on('close', (code) => {
|
|
230
|
+
if (didSucceed(code)) {
|
|
231
|
+
resolve('pcf project created');
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
reject('Ensure the Power Platform CLI is installed. Command must be run from within Visual Studio Code if using the Power Platform Extension');
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
pac.on('error', () => {
|
|
238
|
+
reject('Ensure the Power Platform CLI is installed. Command must be run from within Visual Studio Code if using the Power Platform Extension');
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
},
|
|
216
242
|
{
|
|
217
|
-
type: '
|
|
243
|
+
type: 'add',
|
|
244
|
+
templateFile: '../plop-templates/pcf/tsconfig.json',
|
|
245
|
+
path: path_1.default.resolve(process.cwd(), 'tsconfig.json'),
|
|
246
|
+
force: true
|
|
218
247
|
},
|
|
219
248
|
{
|
|
220
249
|
type: 'addMany',
|
|
221
250
|
templateFiles: [
|
|
222
|
-
'../plop-templates/pcf/App.tsx',
|
|
223
|
-
'../plop-templates/pcf/
|
|
251
|
+
'../plop-templates/pcf/App.tsx.hbs',
|
|
252
|
+
'../plop-templates/pcf/AppContext.ts'
|
|
224
253
|
],
|
|
225
254
|
base: '../plop-templates/pcf',
|
|
226
255
|
destination: `${process.cwd()}/{{ name }}`,
|
|
227
|
-
force: true,
|
|
228
256
|
skip: (answers) => {
|
|
229
257
|
if (!answers.react) {
|
|
230
258
|
return 'react not included';
|
|
@@ -233,27 +261,43 @@ exports.default = (plop) => {
|
|
|
233
261
|
}
|
|
234
262
|
},
|
|
235
263
|
{
|
|
236
|
-
type: '
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
264
|
+
type: 'modify',
|
|
265
|
+
path: `${process.cwd()}/{{ name }}/index.ts`,
|
|
266
|
+
pattern: 'import { HelloWorld, IHelloWorldProps } from "./HelloWorld";',
|
|
267
|
+
template: `import { App, IAppProps } from './App';`
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
type: 'modify',
|
|
271
|
+
path: `${process.cwd()}/{{ name }}/index.ts`,
|
|
272
|
+
pattern: 'HelloWorld, props',
|
|
273
|
+
template: 'App, props'
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
type: 'modify',
|
|
277
|
+
path: `${process.cwd()}/{{ name }}/index.ts`,
|
|
278
|
+
pattern: `const props: IHelloWorldProps = { name: 'Hello, World!' };`,
|
|
279
|
+
template: `const props: IAppProps = { context: context };`
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
type: 'addScript',
|
|
283
|
+
data: {
|
|
284
|
+
scriptKey: 'build:prod',
|
|
285
|
+
scriptValue: 'pcf-scripts build --buildMode production'
|
|
245
286
|
}
|
|
246
287
|
},
|
|
288
|
+
async (answers) => {
|
|
289
|
+
await fs_1.default.promises.rm(path_1.default.resolve(process.cwd(), answers.name, 'HelloWorld.tsx'));
|
|
290
|
+
return 'removed HelloWorld component';
|
|
291
|
+
},
|
|
247
292
|
{
|
|
248
293
|
type: 'npmInstall',
|
|
249
294
|
data: {
|
|
250
295
|
projectType: 'pcf'
|
|
251
296
|
},
|
|
252
297
|
skip: (answers) => {
|
|
253
|
-
if (
|
|
254
|
-
return '
|
|
298
|
+
if (answers.package === 'npm') {
|
|
299
|
+
return 'npm packages already installed';
|
|
255
300
|
}
|
|
256
|
-
return;
|
|
257
301
|
}
|
|
258
302
|
}
|
|
259
303
|
]
|
|
@@ -272,7 +316,8 @@ exports.default = (plop) => {
|
|
|
272
316
|
name: 'namespace',
|
|
273
317
|
message: 'namespace for form and ribbon scripts:'
|
|
274
318
|
},
|
|
275
|
-
|
|
319
|
+
packageQuestion,
|
|
320
|
+
...sharedQuestions
|
|
276
321
|
],
|
|
277
322
|
actions: [
|
|
278
323
|
{
|
|
@@ -281,6 +326,12 @@ exports.default = (plop) => {
|
|
|
281
326
|
base: '../plop-templates/webresource',
|
|
282
327
|
destination: process.cwd(),
|
|
283
328
|
force: true
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
type: 'npmInstall',
|
|
332
|
+
data: {
|
|
333
|
+
projectType: 'webresource'
|
|
334
|
+
}
|
|
284
335
|
}
|
|
285
336
|
]
|
|
286
337
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-powerapps-project",
|
|
3
3
|
"description": "💧 plop generator for Dataverse development",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.21.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"main": "lib/index.js",
|
|
@@ -23,11 +23,10 @@
|
|
|
23
23
|
"clean": "rimraf lib"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"envinfo": "^7.8.1",
|
|
27
26
|
"plop": "^2.7.6"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
30
|
-
"@types/
|
|
31
|
-
"
|
|
29
|
+
"@types/node": "^14.14.21",
|
|
30
|
+
"node-plop": "^0.26.3"
|
|
32
31
|
}
|
|
33
32
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IInputs } from './generated/ManifestTypes';
|
|
3
|
+
import AppContext from './AppContext';
|
|
4
|
+
|
|
5
|
+
export interface IAppProps {
|
|
6
|
+
context: ComponentFramework.Context<IInputs>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const App = React.memo((props: IAppProps) => {
|
|
10
|
+
const {
|
|
11
|
+
context,
|
|
12
|
+
} = props;
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<AppContext.Provider value=\{{ context: context }}>
|
|
16
|
+
</AppContext.Provider>
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
App.displayName = 'App';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IInputs } from './generated/ManifestTypes';
|
|
3
|
+
|
|
4
|
+
interface IAppContext {
|
|
5
|
+
context: ComponentFramework.Context<IInputs>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const AppContext = React.createContext<IAppContext>({} as IAppContext);
|
|
9
|
+
|
|
10
|
+
export default AppContext;
|
package/lib/getEnvInfo.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
exports.initialize = exports.getEnvInfo = void 0;
|
|
7
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
-
const envinfo_1 = __importDefault(require("envinfo"));
|
|
9
|
-
const os_1 = __importDefault(require("os"));
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
let envInfoCache;
|
|
12
|
-
const getEnvInfo = () => {
|
|
13
|
-
return envInfoCache;
|
|
14
|
-
};
|
|
15
|
-
exports.getEnvInfo = getEnvInfo;
|
|
16
|
-
const initialize = async () => {
|
|
17
|
-
envInfoCache = JSON.parse(await envinfo_1.default.run({
|
|
18
|
-
Binaries: ['Yarn', 'npm']
|
|
19
|
-
}, { json: true, showNotFound: false }));
|
|
20
|
-
if (envInfoCache.Binaries.Yarn) {
|
|
21
|
-
envInfoCache.Binaries.Yarn.path = expandHome(envInfoCache.Binaries.Yarn.path);
|
|
22
|
-
}
|
|
23
|
-
if (envInfoCache.Binaries.npm) {
|
|
24
|
-
envInfoCache.Binaries.npm.path = expandHome(envInfoCache.Binaries.npm.path);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
exports.initialize = initialize;
|
|
28
|
-
const expandHome = (pathString) => {
|
|
29
|
-
if (pathString.startsWith('~' + path_1.default.sep)) {
|
|
30
|
-
return pathString.replace('~', os_1.default.homedir());
|
|
31
|
-
}
|
|
32
|
-
return pathString;
|
|
33
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ThemeProvider } from '@fluentui/react/lib/utilities/ThemeProvider/ThemeProvider';
|
|
3
|
-
|
|
4
|
-
export interface AppProps {
|
|
5
|
-
isTestHarness: boolean;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const App = React.memo((props: AppProps) => {
|
|
9
|
-
const {
|
|
10
|
-
isTestHarness
|
|
11
|
-
} = props;
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<ThemeProvider dir='ltr'>
|
|
15
|
-
</ThemeProvider>
|
|
16
|
-
);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
App.displayName = 'App';
|
|
20
|
-
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { IInputs, IOutputs } from "./generated/ManifestTypes";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import ReactDOM from 'react-dom';
|
|
4
|
-
import { initializeIcons } from '@fluentui/font-icons-mdl2';
|
|
5
|
-
|
|
6
|
-
import { App, AppProps } from './App';
|
|
7
|
-
|
|
8
|
-
export class {{name}} implements ComponentFramework.StandardControl<IInputs, IOutputs> {
|
|
9
|
-
container: HTMLDivElement;
|
|
10
|
-
root: Root;
|
|
11
|
-
context: ComponentFramework.Context<IInputs>;
|
|
12
|
-
isTestHarness: boolean;
|
|
13
|
-
props: AppProps;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Empty constructor.
|
|
17
|
-
*/
|
|
18
|
-
constructor() {
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Used to initialize the control instance. Controls can kick off remote server calls and other initialization actions here.
|
|
24
|
-
* Data-set values are not initialized here, use updateView.
|
|
25
|
-
* @param context The entire property bag available to control via Context Object; It contains values as set up by the customizer mapped to property names defined in the manifest, as well as utility functions.
|
|
26
|
-
* @param notifyOutputChanged A callback method to alert the framework that the control has new outputs ready to be retrieved asynchronously.
|
|
27
|
-
* @param state A piece of data that persists in one session for a single user. Can be set at any point in a controls life cycle by calling 'setControlState' in the Mode interface.
|
|
28
|
-
* @param container If a control is marked control-type='standard', it will receive an empty div element within which it can render its content.
|
|
29
|
-
*/
|
|
30
|
-
public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container: HTMLDivElement): void {
|
|
31
|
-
initializeIcons(undefined, { disableWarnings: true });
|
|
32
|
-
|
|
33
|
-
this.container = container;
|
|
34
|
-
this.context = context;
|
|
35
|
-
this.isTestHarness = document.getElementById('control-dimensions') !== null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Called when any value in the property bag has changed. This includes field values, data-sets, global values such as container height and width, offline status, control metadata values such as label, visible, etc.
|
|
41
|
-
* @param context The entire property bag available to control via Context Object; It contains values as set up by the customizer mapped to names defined in the manifest, as well as utility functions
|
|
42
|
-
*/
|
|
43
|
-
public updateView(context: ComponentFramework.Context<IInputs>): void {
|
|
44
|
-
this.props = {
|
|
45
|
-
isTestHarness: this.isTestHarness
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
ReactDOM.render(
|
|
49
|
-
React.createElement(App, this.props),
|
|
50
|
-
this.container
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* It is called by the framework prior to a control receiving new data.
|
|
56
|
-
* @returns an object based on nomenclature defined in manifest, expecting object[s] for property marked as “bound” or “output”
|
|
57
|
-
*/
|
|
58
|
-
public getOutputs(): IOutputs {
|
|
59
|
-
return {};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Called when the control is to be removed from the DOM tree. Controls should use this call for cleanup.
|
|
64
|
-
* i.e. cancelling any pending remote calls, removing listeners, etc.
|
|
65
|
-
*/
|
|
66
|
-
public destroy(): void {
|
|
67
|
-
ReactDOM.unmountComponentAtNode(this.container);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
}
|