create-powerapps-project 0.21.2 → 0.21.3
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 +10 -5
- package/lib/nuget.js +18 -10
- package/lib/packageManager.js +10 -5
- package/lib/plopfile.js +43 -15
- package/package.json +1 -1
- package/plop-templates/webresource/.eslintrc.js +23 -0
package/lib/index.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const plop_1 = require("plop");
|
|
9
|
+
plop_1.Plop.launch({
|
|
5
10
|
cwd: process.cwd(),
|
|
6
|
-
configPath:
|
|
11
|
+
configPath: node_path_1.default.join(__dirname, 'plopfile.js')
|
|
7
12
|
}, env => {
|
|
8
13
|
const options = {
|
|
9
14
|
...env,
|
|
10
15
|
dest: process.cwd() // this will make the destination path to be based on the cwd when calling the wrapper
|
|
11
16
|
};
|
|
12
|
-
return run(options, undefined, true);
|
|
17
|
+
return (0, plop_1.run)(options, undefined, true);
|
|
13
18
|
});
|
package/lib/nuget.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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.install = exports.getNugetPackageVersions = void 0;
|
|
7
|
+
const https_1 = __importDefault(require("https"));
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
const getNugetPackageVersions = (name) => {
|
|
4
10
|
return new Promise((resolve, reject) => {
|
|
5
|
-
|
|
11
|
+
https_1.default.get(`https://azuresearch-usnc.nuget.org/query?q=packageid:${name}`, (response) => {
|
|
6
12
|
let body = '';
|
|
7
13
|
response.on('data', (d) => {
|
|
8
14
|
body += d;
|
|
@@ -19,30 +25,32 @@ export const getNugetPackageVersions = (name) => {
|
|
|
19
25
|
});
|
|
20
26
|
});
|
|
21
27
|
};
|
|
22
|
-
|
|
28
|
+
exports.getNugetPackageVersions = getNugetPackageVersions;
|
|
29
|
+
const install = (project, sdkVersion, xrmVersion) => {
|
|
23
30
|
// Add solution
|
|
24
|
-
spawnSync('dotnet', ['new', 'sln', '-n', project], {
|
|
31
|
+
(0, child_process_1.spawnSync)('dotnet', ['new', 'sln', '-n', project], {
|
|
25
32
|
cwd: process.cwd(),
|
|
26
33
|
stdio: 'inherit'
|
|
27
34
|
});
|
|
28
|
-
spawnSync('dotnet', ['sln', 'add', `${project}.csproj`], {
|
|
35
|
+
(0, child_process_1.spawnSync)('dotnet', ['sln', 'add', `${project}.csproj`], {
|
|
29
36
|
cwd: process.cwd(),
|
|
30
37
|
stdio: 'inherit'
|
|
31
38
|
});
|
|
32
39
|
// Install nuget packages
|
|
33
|
-
spawnSync('dotnet', ['add', 'package', 'Microsoft.CrmSdk.Workflow', '-v', sdkVersion, '-n'], {
|
|
40
|
+
(0, child_process_1.spawnSync)('dotnet', ['add', 'package', 'Microsoft.CrmSdk.Workflow', '-v', sdkVersion, '-n'], {
|
|
34
41
|
cwd: process.cwd(),
|
|
35
42
|
stdio: 'inherit'
|
|
36
43
|
});
|
|
37
|
-
spawnSync('dotnet', ['add', 'package', 'JourneyTeam.Xrm', '-v', xrmVersion, '-n'], {
|
|
44
|
+
(0, child_process_1.spawnSync)('dotnet', ['add', 'package', 'JourneyTeam.Xrm', '-v', xrmVersion, '-n'], {
|
|
38
45
|
cwd: process.cwd(),
|
|
39
46
|
stdio: 'inherit'
|
|
40
47
|
});
|
|
41
48
|
if (process.env.JEST_WORKER_ID !== undefined) {
|
|
42
49
|
return;
|
|
43
50
|
}
|
|
44
|
-
spawnSync('dotnet', ['restore'], {
|
|
51
|
+
(0, child_process_1.spawnSync)('dotnet', ['restore'], {
|
|
45
52
|
cwd: process.cwd(),
|
|
46
53
|
stdio: 'inherit'
|
|
47
54
|
});
|
|
48
55
|
};
|
|
56
|
+
exports.install = install;
|
package/lib/packageManager.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.install = void 0;
|
|
1
4
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
|
|
3
|
-
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const install = (cwd, type, packageManager) => {
|
|
4
7
|
if (process.env.JEST_WORKER_ID != undefined) {
|
|
5
8
|
return;
|
|
6
9
|
}
|
|
7
10
|
if (type === 'pcf') {
|
|
8
|
-
spawnSync(packageManager, ['install'], { stdio: 'inherit', shell: true });
|
|
11
|
+
(0, child_process_1.spawnSync)(packageManager, ['install'], { stdio: 'inherit', shell: true });
|
|
9
12
|
}
|
|
10
13
|
else {
|
|
11
14
|
const packages = getPackages(type);
|
|
12
|
-
spawnSync(packageManager, ['add', ...packages.devDependencies], { stdio: 'inherit', shell: true });
|
|
15
|
+
(0, child_process_1.spawnSync)(packageManager, ['add', ...packages.devDependencies], { stdio: 'inherit', shell: true });
|
|
13
16
|
if (packages.dependencies) {
|
|
14
|
-
spawnSync(packageManager, ['add', ...packages.dependencies], { stdio: 'inherit', shell: true });
|
|
17
|
+
(0, child_process_1.spawnSync)(packageManager, ['add', ...packages.dependencies], { stdio: 'inherit', shell: true });
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
20
|
};
|
|
21
|
+
exports.install = install;
|
|
18
22
|
function getPackages(type) {
|
|
19
23
|
const packages = {
|
|
20
24
|
devDependencies: [
|
|
@@ -43,6 +47,7 @@ function getPackages(type) {
|
|
|
43
47
|
'webpack-cli',
|
|
44
48
|
'cross-spawn',
|
|
45
49
|
'ts-node',
|
|
50
|
+
'@microsoft/eslint-plugin-power-apps',
|
|
46
51
|
'-D'
|
|
47
52
|
];
|
|
48
53
|
packages.dependencies = ['core-js', 'regenerator-runtime', 'powerapps-common', 'dataverse-webapi'];
|
package/lib/plopfile.js
CHANGED
|
@@ -1,13 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const path_1 = __importDefault(require("path"));
|
|
30
|
+
const child_process_1 = require("child_process");
|
|
31
|
+
const fs_1 = __importDefault(require("fs"));
|
|
32
|
+
const nuget = __importStar(require("./nuget"));
|
|
33
|
+
const pkg = __importStar(require("./packageManager"));
|
|
6
34
|
const didSucceed = (code) => `${code}` === '0';
|
|
7
35
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
8
36
|
const version = require('../package').version;
|
|
9
37
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
10
|
-
|
|
38
|
+
exports.default = (plop) => {
|
|
11
39
|
plop.setWelcomeMessage(`Creating new Dataverse project using create-powerapps-project v${version}. Please choose type of project to create.`);
|
|
12
40
|
const packageQuestion = {
|
|
13
41
|
type: 'list',
|
|
@@ -39,11 +67,11 @@ export default (plop) => {
|
|
|
39
67
|
}
|
|
40
68
|
];
|
|
41
69
|
plop.setActionType('addScript', async (answers) => {
|
|
42
|
-
const packagePath =
|
|
70
|
+
const packagePath = path_1.default.resolve(process.cwd(), 'package.json');
|
|
43
71
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
44
72
|
const packageJson = require(packagePath);
|
|
45
73
|
packageJson.scripts[answers.scriptKey] = answers.scriptValue;
|
|
46
|
-
await
|
|
74
|
+
await fs_1.default.promises.writeFile(packagePath, JSON.stringify(packageJson, null, 4), 'utf8');
|
|
47
75
|
return `added ${answers.scriptKey} script to package.json`;
|
|
48
76
|
});
|
|
49
77
|
plop.setActionType('npmInstall', (answers) => {
|
|
@@ -103,7 +131,7 @@ export default (plop) => {
|
|
|
103
131
|
{
|
|
104
132
|
type: 'add',
|
|
105
133
|
templateFile: '../plop-templates/assembly/assembly.csproj.hbs',
|
|
106
|
-
path:
|
|
134
|
+
path: path_1.default.resolve(process.cwd(), '{{name}}.csproj'),
|
|
107
135
|
},
|
|
108
136
|
{
|
|
109
137
|
type: 'addMany',
|
|
@@ -121,13 +149,13 @@ export default (plop) => {
|
|
|
121
149
|
force: true
|
|
122
150
|
},
|
|
123
151
|
(answers) => {
|
|
124
|
-
const keyPath =
|
|
152
|
+
const keyPath = path_1.default.resolve(process.cwd(), `${answers.name}.snk`);
|
|
125
153
|
return new Promise((resolve, reject) => {
|
|
126
154
|
if (process.env.JEST_WORKER_ID !== undefined) {
|
|
127
155
|
resolve('Testing so no need to sign');
|
|
128
156
|
}
|
|
129
157
|
else {
|
|
130
|
-
const sign = spawn(
|
|
158
|
+
const sign = (0, child_process_1.spawn)(path_1.default.resolve(__dirname, '..', 'bin', 'sn.exe'), ['-q', '-k', keyPath], { stdio: 'inherit' });
|
|
131
159
|
sign.on('close', (code) => {
|
|
132
160
|
if (didSucceed(code)) {
|
|
133
161
|
resolve('signed assembly');
|
|
@@ -199,7 +227,7 @@ export default (plop) => {
|
|
|
199
227
|
args.push('-npm', 'true');
|
|
200
228
|
}
|
|
201
229
|
return new Promise((resolve, reject) => {
|
|
202
|
-
const pac = spawn('pac', args, { stdio: 'inherit' });
|
|
230
|
+
const pac = (0, child_process_1.spawn)('pac', args, { stdio: 'inherit' });
|
|
203
231
|
pac.on('close', (code) => {
|
|
204
232
|
if (didSucceed(code)) {
|
|
205
233
|
resolve('pcf project created');
|
|
@@ -216,7 +244,7 @@ export default (plop) => {
|
|
|
216
244
|
{
|
|
217
245
|
type: 'add',
|
|
218
246
|
templateFile: '../plop-templates/pcf/tsconfig.json',
|
|
219
|
-
path:
|
|
247
|
+
path: path_1.default.resolve(process.cwd(), 'tsconfig.json'),
|
|
220
248
|
force: true
|
|
221
249
|
},
|
|
222
250
|
{
|
|
@@ -260,7 +288,7 @@ export default (plop) => {
|
|
|
260
288
|
}
|
|
261
289
|
},
|
|
262
290
|
async (answers) => {
|
|
263
|
-
await
|
|
291
|
+
await fs_1.default.promises.rm(path_1.default.resolve(process.cwd(), answers.name, 'HelloWorld.tsx'));
|
|
264
292
|
return 'removed HelloWorld component';
|
|
265
293
|
},
|
|
266
294
|
{
|
|
@@ -283,7 +311,7 @@ export default (plop) => {
|
|
|
283
311
|
type: 'input',
|
|
284
312
|
name: 'name',
|
|
285
313
|
message: 'project name',
|
|
286
|
-
default:
|
|
314
|
+
default: path_1.default.basename(process.cwd())
|
|
287
315
|
},
|
|
288
316
|
{
|
|
289
317
|
type: 'input',
|
package/package.json
CHANGED
|
@@ -9,4 +9,27 @@ module.exports = {
|
|
|
9
9
|
'eslint:recommended',
|
|
10
10
|
'plugin:@typescript-eslint/recommended',
|
|
11
11
|
],
|
|
12
|
+
rules: {
|
|
13
|
+
"@microsoft/power-apps/avoid-2011-api": "error",
|
|
14
|
+
"@microsoft/power-apps/avoid-browser-specific-api": "error",
|
|
15
|
+
"@microsoft/power-apps/avoid-crm2011-service-odata": "warn",
|
|
16
|
+
"@microsoft/power-apps/avoid-crm2011-service-soap": "warn",
|
|
17
|
+
"@microsoft/power-apps/avoid-dom-form-event": "warn",
|
|
18
|
+
"@microsoft/power-apps/avoid-dom-form": "warn",
|
|
19
|
+
"@microsoft/power-apps/avoid-isactivitytype": "warn",
|
|
20
|
+
"@microsoft/power-apps/avoid-modals": "warn",
|
|
21
|
+
"@microsoft/power-apps/avoid-unpub-api": "warn",
|
|
22
|
+
"@microsoft/power-apps/avoid-window-top": "warn",
|
|
23
|
+
"@microsoft/power-apps/do-not-make-parent-assumption": "warn",
|
|
24
|
+
"@microsoft/power-apps/use-async": "error",
|
|
25
|
+
"@microsoft/power-apps/use-cached-webresource": "warn",
|
|
26
|
+
"@microsoft/power-apps/use-client-context": "warn",
|
|
27
|
+
"@microsoft/power-apps/use-global-context": "error",
|
|
28
|
+
"@microsoft/power-apps/use-grid-api": "warn",
|
|
29
|
+
"@microsoft/power-apps/use-navigation-api": "warn",
|
|
30
|
+
"@microsoft/power-apps/use-offline": "warn",
|
|
31
|
+
"@microsoft/power-apps/use-org-setting": "error",
|
|
32
|
+
"@microsoft/power-apps/use-relative-uri": "warn",
|
|
33
|
+
"@microsoft/power-apps/use-utility-dialogs": "warn"
|
|
34
|
+
}
|
|
12
35
|
};
|