create-powerapps-project 0.24.5 → 0.25.1

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.
@@ -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: (server) => {
31
+ validate: (answer) => {
32
32
  try {
33
- const url = new URL(server);
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: (prefix) => {
69
- if (prefix.slice(-1) === '_') {
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: (name) => {
106
- const validNamespace = name.replace(/[^a-zA-Z.]+/g, '');
107
- if (validNamespace !== name) {
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 = name.split('.');
110
+ const namespace = answer.split('.');
111
111
  for (const item of namespace) {
112
- const title = plop.renderString('{{titleCase name}}', { name: item });
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
- skip: (answers) => {
333
- if (answers.package === 'npm') {
334
- return 'npm packages already installed';
359
+ data: {
360
+ packages: {
361
+ devDependencies: [
362
+ 'powerapps-project-pcf'
363
+ ]
335
364
  }
336
365
  }
337
366
  }
@@ -359,7 +388,7 @@ exports.default = (plop) => {
359
388
  return [
360
389
  {
361
390
  type: 'addMany',
362
- templateFiles: ['../plop-templates/webresource/*', '../plop-templates/webresource/.*'],
391
+ templateFiles: ['../plop-templates/webresource/*', '../plop-templates/webresource/.*', '.gitignore'],
363
392
  base: '../plop-templates/webresource',
364
393
  destination: process.cwd(),
365
394
  force: true
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.24.5",
4
+ "version": "0.25.1",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
7
7
  "bin": {
@@ -0,0 +1,3 @@
1
+ * text=auto eol=lf
2
+ *.{cmd,[cC][mM][dD]} text eol=crlf
3
+ *.{bat,[bB][aA][tT]} text eol=crlf
@@ -25,7 +25,7 @@
25
25
  "/consoleloggerparameters:NoSummary"
26
26
  ],
27
27
  "problemMatcher": "$msCompile"
28
- }
28
+ },
29
29
  {
30
30
  "label": "deploy",
31
31
  "type":"npm",
@@ -8,5 +8,6 @@
8
8
  "isolationmode": "{{isolation}}",
9
9
  "version": "1.0.0.0",
10
10
  "publickeytoken": "{{name}}.snk",
11
- "types": []
11
+ "types": [],
12
+ "customApis": []
12
13
  }
@@ -12,6 +12,7 @@
12
12
  "isolationmode": "{{isolation}}",
13
13
  "version": "1.0.0.0",
14
14
  "publickeytoken": "{{name}}.snk",
15
- "types": []
15
+ "types": [],
16
+ "customApis": []
16
17
  }
17
18
  }
@@ -0,0 +1,3 @@
1
+ * text=auto eol=lf
2
+ *.{cmd,[cC][mM][dD]} text eol=crlf
3
+ *.{bat,[bB][aA][tT]} text eol=crlf
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IInputs } from './generated/ManifestTypes';
3
- import AppContext from './AppContext';
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
- <AppContext.Provider value=\{{ context: context }}>
16
- </AppContext.Provider>
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
- interface IAppContext {
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 AppContext = React.createContext<IAppContext>({} as IAppContext);
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 default AppContext;
17
+ export const useAppContext = (): ComponentFramework.Context<IInputs> => React.useContext(AppContext);
@@ -0,0 +1,3 @@
1
+ module.exports = function (plop) {
2
+ plop.load('powerapps-project-pcf');
3
+ };
@@ -0,0 +1,3 @@
1
+ * text=auto eol=lf
2
+ *.{cmd,[cC][mM][dD]} text eol=crlf
3
+ *.{bat,[bB][aA][tT]} text eol=crlf