create-powerapps-project 1.4.6 → 1.5.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
CHANGED
|
@@ -58,7 +58,7 @@ export default (plop) => {
|
|
|
58
58
|
plop.setActionType('runPcf', async (answers) => {
|
|
59
59
|
const args = ['pcf', 'init', '-ns', answers.namespace, '-n', answers.name, '-t', answers.template, '-npm', 'false'];
|
|
60
60
|
// Set framework to React if selected
|
|
61
|
-
if (answers.react) {
|
|
61
|
+
if (answers.react && answers.fluentVersion === 8) {
|
|
62
62
|
args.push('-fw', 'react');
|
|
63
63
|
}
|
|
64
64
|
return new Promise((resolve, reject) => {
|
package/lib/plopfile.js
CHANGED
|
@@ -288,6 +288,16 @@ export default async (plop) => {
|
|
|
288
288
|
name: 'react',
|
|
289
289
|
message: 'use react?'
|
|
290
290
|
},
|
|
291
|
+
{
|
|
292
|
+
type: 'list',
|
|
293
|
+
name: 'fluentVersion',
|
|
294
|
+
message: 'select Fluent UI version',
|
|
295
|
+
choices: [
|
|
296
|
+
{ name: 'v8', value: 8 },
|
|
297
|
+
{ name: 'v9', value: 9 }
|
|
298
|
+
],
|
|
299
|
+
when: (answers) => answers.react
|
|
300
|
+
},
|
|
291
301
|
packageQuestion
|
|
292
302
|
],
|
|
293
303
|
actions: (data) => {
|
|
@@ -328,6 +338,23 @@ export default async (plop) => {
|
|
|
328
338
|
if (!answers.react) {
|
|
329
339
|
return 'react not included';
|
|
330
340
|
}
|
|
341
|
+
if (answers.fluentVersion === 9) {
|
|
342
|
+
return 'using fluent v9';
|
|
343
|
+
}
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
type: 'add',
|
|
349
|
+
templateFile: '../plop-templates/pcf/AppFluent9.tsx',
|
|
350
|
+
path: path.resolve(process.cwd(), '{{name}}', 'App.tsx'),
|
|
351
|
+
skip: (answers) => {
|
|
352
|
+
if (!answers.react) {
|
|
353
|
+
return 'react not included';
|
|
354
|
+
}
|
|
355
|
+
if (answers.fluentVersion === 8) {
|
|
356
|
+
return 'using fluent v8';
|
|
357
|
+
}
|
|
331
358
|
return;
|
|
332
359
|
}
|
|
333
360
|
},
|
|
@@ -342,6 +369,18 @@ export default async (plop) => {
|
|
|
342
369
|
return;
|
|
343
370
|
}
|
|
344
371
|
},
|
|
372
|
+
{
|
|
373
|
+
type: 'add',
|
|
374
|
+
templateFile: '../plop-templates/pcf/index.ts.hbs',
|
|
375
|
+
path: path.resolve(process.cwd(), '{{name}}', 'index.ts'),
|
|
376
|
+
force: true,
|
|
377
|
+
skip: (answers) => {
|
|
378
|
+
if (!answers.react || answers.fluentVersion === 8) {
|
|
379
|
+
return 'not using Fluent UI v9';
|
|
380
|
+
}
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
},
|
|
345
384
|
{
|
|
346
385
|
type: 'modify',
|
|
347
386
|
path: `${process.cwd()}/{{name}}/index.ts`,
|
|
@@ -389,7 +428,7 @@ export default async (plop) => {
|
|
|
389
428
|
}
|
|
390
429
|
},
|
|
391
430
|
async (answers) => {
|
|
392
|
-
if (answers.react) {
|
|
431
|
+
if (answers.react && answers.fluentVersion === 8) {
|
|
393
432
|
await fs.promises.rm(path.resolve(process.cwd(), answers.name, 'HelloWorld.tsx'));
|
|
394
433
|
return 'removed HelloWorld component';
|
|
395
434
|
}
|
|
@@ -416,6 +455,34 @@ export default async (plop) => {
|
|
|
416
455
|
if (!answers.react) {
|
|
417
456
|
return 'react not included';
|
|
418
457
|
}
|
|
458
|
+
if (answers.fluentVersion === 9) {
|
|
459
|
+
return 'using fluent v9';
|
|
460
|
+
}
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
type: 'npmInstall',
|
|
466
|
+
data: {
|
|
467
|
+
packages: {
|
|
468
|
+
devDependencies: [
|
|
469
|
+
'powerapps-project-pcf',
|
|
470
|
+
'@types/react@16',
|
|
471
|
+
'@types/react-dom@16',
|
|
472
|
+
'eslint-plugin-react-hooks',
|
|
473
|
+
'@types/xrm',
|
|
474
|
+
'eslint-plugin-react'
|
|
475
|
+
],
|
|
476
|
+
dependencies: ['@fluentui/react-hooks', '@fluentui/react-components', '@fluentui/react-icons', 'react@16', 'react-dom@16']
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
skip: (answers) => {
|
|
480
|
+
if (!answers.react) {
|
|
481
|
+
return 'react not included';
|
|
482
|
+
}
|
|
483
|
+
if (answers.fluentVersion === 8) {
|
|
484
|
+
return 'using fluent v8';
|
|
485
|
+
}
|
|
419
486
|
return;
|
|
420
487
|
}
|
|
421
488
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IInputs } from './generated/ManifestTypes';
|
|
3
3
|
import { AppContext } from './contexts/AppContext';
|
|
4
|
-
import { initializeIcons } from '@fluentui/react/lib/Icons';
|
|
5
|
-
|
|
6
|
-
initializeIcons();
|
|
7
4
|
|
|
8
5
|
export const App = (props: { context: ComponentFramework.Context<IInputs>; }) => {
|
|
9
6
|
const {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IInputs } from './generated/ManifestTypes';
|
|
3
|
+
import { AppContext } from './contexts/AppContext';
|
|
4
|
+
import { FluentProvider, IdPrefixProvider, webLightTheme } from '@fluentui/react-components';
|
|
5
|
+
|
|
6
|
+
export const App = (props: { context: ComponentFramework.Context<IInputs>; }) => {
|
|
7
|
+
const {
|
|
8
|
+
context
|
|
9
|
+
} = props;
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<IdPrefixProvider value="AdasCertification">
|
|
13
|
+
<FluentProvider theme={webLightTheme}>
|
|
14
|
+
<AppContext.Provider value=\{{ context }}>
|
|
15
|
+
</AppContext.Provider>
|
|
16
|
+
</FluentProvider>
|
|
17
|
+
</IdPrefixProvider>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
App.displayName = 'App';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { IInputs, IOutputs } from './generated/ManifestTypes';
|
|
2
|
+
import { App } from './App';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
export class {{name}} implements ComponentFramework.StandardControl<IInputs, IOutputs> {
|
|
7
|
+
container: HTMLDivElement;
|
|
8
|
+
context: ComponentFramework.Context<IInputs>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Used to initialize the control instance. Controls can kick off remote server calls and other initialization actions here.
|
|
12
|
+
* Data-set values are not initialized here, use updateView.
|
|
13
|
+
* @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.
|
|
14
|
+
* @param notifyOutputChanged A callback method to alert the framework that the control has new outputs ready to be retrieved asynchronously.
|
|
15
|
+
* @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.
|
|
16
|
+
* @param container If a control is marked control-type='standard', it will receive an empty div element within which it can render its content.
|
|
17
|
+
*/
|
|
18
|
+
public init(
|
|
19
|
+
context: ComponentFramework.Context<IInputs>,
|
|
20
|
+
notifyOutputChanged: () => void,
|
|
21
|
+
state: ComponentFramework.Dictionary,
|
|
22
|
+
container: HTMLDivElement
|
|
23
|
+
): void {
|
|
24
|
+
this.context = context;
|
|
25
|
+
this.container = container;
|
|
26
|
+
this.context.mode.trackContainerResize(true);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 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.
|
|
31
|
+
* @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
|
|
32
|
+
*/
|
|
33
|
+
public updateView(context: ComponentFramework.Context<IInputs>): void {
|
|
34
|
+
ReactDOM.render(
|
|
35
|
+
React.createElement(App, {
|
|
36
|
+
context: context
|
|
37
|
+
}),
|
|
38
|
+
this.container
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* It is called by the framework prior to a control receiving new data.
|
|
44
|
+
* @returns an object based on nomenclature defined in manifest, expecting object[s] for property marked as “bound” or “output”
|
|
45
|
+
*/
|
|
46
|
+
public getOutputs(): IOutputs {
|
|
47
|
+
return {
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Called when the control is to be removed from the DOM tree. Controls should use this call for cleanup.
|
|
53
|
+
* i.e. cancelling any pending remote calls, removing listeners, etc.
|
|
54
|
+
*/
|
|
55
|
+
public destroy(): void {
|
|
56
|
+
// Add code to cleanup control if necessary
|
|
57
|
+
}
|
|
58
|
+
}
|