create-powerapps-project 0.24.4 → 0.25.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/plopActions.js +1 -7
- package/lib/plopfile.js +41 -12
- package/package.json +1 -1
- package/plop-templates/assembly/.gitattributes +3 -0
- package/plop-templates/assembly/.vscode/tasks.json.hbs +1 -1
- package/plop-templates/assembly/dataverse.config.json.hbs +2 -1
- package/plop-templates/assembly/dataverse.package.config.json.hbs +2 -1
- package/plop-templates/pcf/.gitattributes +3 -0
- package/plop-templates/pcf/App.tsx.hbs +3 -3
- package/plop-templates/pcf/AppContext.ts +10 -3
- package/plop-templates/pcf/plopfile.js +3 -0
- package/plop-templates/webresource/.gitattributes +3 -0
- package/plop-templates/webresource/.prettierrc.json +2 -1
package/lib/plopActions.js
CHANGED
|
@@ -79,17 +79,11 @@ exports.default = (plop) => {
|
|
|
79
79
|
});
|
|
80
80
|
});
|
|
81
81
|
plop.setActionType('runPcf', async (answers) => {
|
|
82
|
-
const args = ['pcf', 'init', '-ns', answers.namespace, '-n', answers.name, '-t', answers.template];
|
|
82
|
+
const args = ['pcf', 'init', '-ns', answers.namespace, '-n', answers.name, '-t', answers.template, '-npm', 'false'];
|
|
83
83
|
// Set framework to React if selected
|
|
84
84
|
if (answers.react) {
|
|
85
85
|
args.push('-fw', 'react');
|
|
86
86
|
}
|
|
87
|
-
if (process.env.JEST_WORKER_ID !== undefined || answers.package !== 'npm') {
|
|
88
|
-
args.push('-npm', 'false');
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
args.push('-npm', 'true');
|
|
92
|
-
}
|
|
93
87
|
return new Promise((resolve, reject) => {
|
|
94
88
|
const pac = (0, child_process_1.spawn)('pac', args, { stdio: 'inherit' });
|
|
95
89
|
pac.on('close', (code) => {
|
package/lib/plopfile.js
CHANGED
|
@@ -28,9 +28,9 @@ exports.default = (plop) => {
|
|
|
28
28
|
type: 'input',
|
|
29
29
|
name: 'server',
|
|
30
30
|
message: 'enter dataverse url (https://org.crm.dynamics.com):',
|
|
31
|
-
validate: (
|
|
31
|
+
validate: (answer) => {
|
|
32
32
|
try {
|
|
33
|
-
const url = new URL(
|
|
33
|
+
const url = new URL(answer);
|
|
34
34
|
if (url.protocol !== 'https:') {
|
|
35
35
|
return 'server should begin with https';
|
|
36
36
|
}
|
|
@@ -65,8 +65,8 @@ exports.default = (plop) => {
|
|
|
65
65
|
type: 'input',
|
|
66
66
|
name: 'prefix',
|
|
67
67
|
message: 'publisher prefix (no underscore):',
|
|
68
|
-
validate: (
|
|
69
|
-
if (
|
|
68
|
+
validate: (answer) => {
|
|
69
|
+
if (answer.slice(-1) === '_') {
|
|
70
70
|
return 'enter publisher prefix without the underscore';
|
|
71
71
|
}
|
|
72
72
|
return true;
|
|
@@ -102,14 +102,14 @@ exports.default = (plop) => {
|
|
|
102
102
|
type: 'input',
|
|
103
103
|
name: 'name',
|
|
104
104
|
message: 'default C# namespace (Company.Crm.Plugins):',
|
|
105
|
-
validate: (
|
|
106
|
-
const validNamespace =
|
|
107
|
-
if (validNamespace !==
|
|
105
|
+
validate: (answer) => {
|
|
106
|
+
const validNamespace = answer.replace(/[^a-zA-Z.]+/g, '');
|
|
107
|
+
if (validNamespace !== answer) {
|
|
108
108
|
return 'namespace must contain only alpha characters and periods';
|
|
109
109
|
}
|
|
110
|
-
const namespace =
|
|
110
|
+
const namespace = answer.split('.');
|
|
111
111
|
for (const item of namespace) {
|
|
112
|
-
const title = plop.renderString('{{
|
|
112
|
+
const title = plop.renderString('{{pascalCase name}}', { name: item });
|
|
113
113
|
if (title !== item) {
|
|
114
114
|
return `enter namespace using PascalCase`;
|
|
115
115
|
}
|
|
@@ -258,6 +258,11 @@ exports.default = (plop) => {
|
|
|
258
258
|
name: 'name',
|
|
259
259
|
message: 'name'
|
|
260
260
|
},
|
|
261
|
+
{
|
|
262
|
+
type: 'input',
|
|
263
|
+
name: 'prefix',
|
|
264
|
+
message: 'publisher prefix'
|
|
265
|
+
},
|
|
261
266
|
{
|
|
262
267
|
type: 'confirm',
|
|
263
268
|
name: 'react',
|
|
@@ -276,6 +281,18 @@ exports.default = (plop) => {
|
|
|
276
281
|
path: path_1.default.resolve(process.cwd(), 'tsconfig.json'),
|
|
277
282
|
force: true
|
|
278
283
|
},
|
|
284
|
+
{
|
|
285
|
+
type: 'add',
|
|
286
|
+
templateFile: '../plop-templates/pcf/plopfile.js',
|
|
287
|
+
path: path_1.default.resolve(process.cwd(), 'plopfile.js'),
|
|
288
|
+
force: true
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
type: 'add',
|
|
292
|
+
templateFile: '../plop-templates/pcf/.gitattributes',
|
|
293
|
+
path: path_1.default.resolve(process.cwd(), '.gitattributes'),
|
|
294
|
+
force: true
|
|
295
|
+
},
|
|
279
296
|
{
|
|
280
297
|
type: 'addMany',
|
|
281
298
|
templateFiles: [
|
|
@@ -316,6 +333,13 @@ exports.default = (plop) => {
|
|
|
316
333
|
scriptValue: 'pcf-scripts build --buildMode production'
|
|
317
334
|
}
|
|
318
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
|
+
},
|
|
319
343
|
{
|
|
320
344
|
type: 'addScript',
|
|
321
345
|
data: {
|
|
@@ -327,11 +351,16 @@ exports.default = (plop) => {
|
|
|
327
351
|
await fs_1.default.promises.rm(path_1.default.resolve(process.cwd(), answers.name, 'HelloWorld.tsx'));
|
|
328
352
|
return 'removed HelloWorld component';
|
|
329
353
|
},
|
|
354
|
+
{
|
|
355
|
+
type: 'npmInstall'
|
|
356
|
+
},
|
|
330
357
|
{
|
|
331
358
|
type: 'npmInstall',
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
359
|
+
data: {
|
|
360
|
+
packages: {
|
|
361
|
+
devDependencies: [
|
|
362
|
+
'powerapps-project-pcf'
|
|
363
|
+
]
|
|
335
364
|
}
|
|
336
365
|
}
|
|
337
366
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IInputs } from './generated/ManifestTypes';
|
|
3
|
-
import
|
|
3
|
+
import { AppContextProvider } from './AppContext';
|
|
4
4
|
|
|
5
5
|
export interface IAppProps {
|
|
6
6
|
context: ComponentFramework.Context<IInputs>;
|
|
@@ -12,8 +12,8 @@ export const App = React.memo((props: IAppProps) => {
|
|
|
12
12
|
} = props;
|
|
13
13
|
|
|
14
14
|
return (
|
|
15
|
-
<
|
|
16
|
-
</
|
|
15
|
+
<AppContextProvider value=\{{ context: context }}>
|
|
16
|
+
</AppContextProvider>
|
|
17
17
|
);
|
|
18
18
|
});
|
|
19
19
|
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IInputs } from './generated/ManifestTypes';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const AppContext = React.createContext<ComponentFramework.Context<IInputs>>({} as ComponentFramework.Context<IInputs>);
|
|
5
|
+
|
|
6
|
+
interface IAppContextProviderProps {
|
|
5
7
|
context: ComponentFramework.Context<IInputs>;
|
|
8
|
+
children?: React.ReactNode;
|
|
6
9
|
}
|
|
7
10
|
|
|
8
|
-
const
|
|
11
|
+
export const AppContextProvider = (props: IAppContextProviderProps): JSX.Element => {
|
|
12
|
+
const { context, children } = props;
|
|
13
|
+
|
|
14
|
+
return <AppContext.Provider value={context}>{children}</AppContext.Provider>;
|
|
15
|
+
};
|
|
9
16
|
|
|
10
|
-
export
|
|
17
|
+
export const useAppContext = (): ComponentFramework.Context<IInputs> => React.useContext(AppContext);
|