create-powerapps-project 0.15.6 → 0.16.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/CHANGELOG.json CHANGED
@@ -2,7 +2,22 @@
2
2
  "name": "create-powerapps-project",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 17 Jan 2022 15:43:47 GMT",
5
+ "date": "Mon, 07 Feb 2022 22:01:59 GMT",
6
+ "tag": "create-powerapps-project_v0.16.0",
7
+ "version": "0.16.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "derek.finlinson@journeyteam.com",
12
+ "package": "create-powerapps-project",
13
+ "commit": "55d633b2c3064bbdce48c5d314d8e7572a015882",
14
+ "comment": "Add support for PCF projects"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Mon, 17 Jan 2022 15:43:56 GMT",
6
21
  "tag": "create-powerapps-project_v0.15.6",
7
22
  "version": "0.15.6",
8
23
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,17 +1,25 @@
1
1
  # Change Log - create-powerapps-project
2
2
 
3
- This log was last generated on Mon, 17 Jan 2022 15:43:47 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 07 Feb 2022 22:01:59 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## 0.15.6
7
+ ## 0.16.0
8
8
 
9
- Mon, 17 Jan 2022 15:43:47 GMT
9
+ Mon, 07 Feb 2022 22:01:59 GMT
10
10
 
11
- ### Patches
11
+ ### Minor changes
12
12
 
13
- - Rework logger (derek.finlinson@journeyteam.com)
13
+ - Add support for PCF projects (derek.finlinson@journeyteam.com)
14
14
 
15
+ ## 0.15.6
16
+
17
+ Mon, 17 Jan 2022 15:43:56 GMT
18
+
19
+ ### Patches
20
+
21
+ - Rework logger (derek.finlinson@journeyteam.com)
22
+
15
23
  ## 0.15.5
16
24
 
17
25
  Sun, 16 Jan 2022 23:22:22 GMT
package/lib/logger.js CHANGED
@@ -3,20 +3,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.logger = void 0;
6
+ exports.logger = exports.icons = void 0;
7
7
  const kleur_1 = __importDefault(require("kleur"));
8
- const tick = '√', cross = '×';
9
- const log = (method, symbol, ...args) => {
10
- console[method](symbol, ...args);
8
+ const isTest = process.env.JEST_WORKER_ID !== undefined;
9
+ exports.icons = {
10
+ done: kleur_1.default.green('▣'),
11
+ info: kleur_1.default.cyan('!'),
12
+ error: kleur_1.default.red('⨂'),
13
+ warn: kleur_1.default.yellow('‼')
11
14
  };
12
15
  exports.logger = {
13
16
  info(...args) {
14
- log('info', kleur_1.default.green(tick), ...args);
17
+ if (!isTest) {
18
+ console.info(exports.icons.info, ...args);
19
+ }
15
20
  },
16
21
  warn(...args) {
17
- log('warn', kleur_1.default.yellow(cross), ...args);
22
+ if (!isTest) {
23
+ console.warn(exports.icons.warn, ...args);
24
+ }
18
25
  },
19
26
  error(...args) {
20
- log('error', kleur_1.default.red(cross), ...args);
21
- }
27
+ if (!isTest) {
28
+ console.error(exports.icons.error, ...args);
29
+ }
30
+ },
31
+ done(...args) {
32
+ if (!isTest) {
33
+ console.info(exports.icons.info, ...args);
34
+ }
35
+ },
22
36
  };
@@ -29,13 +29,12 @@ const path_1 = __importDefault(require("path"));
29
29
  const plop_1 = require("./plop");
30
30
  const pkg = __importStar(require("./packageManager"));
31
31
  const getEnvInfo_1 = require("./getEnvInfo");
32
- const kleur_1 = __importDefault(require("kleur"));
33
- const tick = '√', pointer = '>';
32
+ const logger_1 = require("../../../logger");
34
33
  exports.default = async (type) => {
35
34
  await (0, getEnvInfo_1.initialize)();
36
35
  const name = path_1.default.basename(process.cwd());
37
- if (!type || (type !== 'webresource' && type !== 'assembly')) {
38
- const invalid = type !== undefined && type !== 'webresource' && type !== 'assembly';
36
+ if (!type || (type !== 'webresource' && type !== 'assembly' && type !== 'pcf')) {
37
+ const invalid = type !== undefined && type !== 'webresource' && type !== 'assembly' && type !== 'pcf';
39
38
  const invalidMessage = invalid ? `${type} is not a valid project type.` : '';
40
39
  const { promptType } = await (0, prompts_1.default)({
41
40
  type: 'select',
@@ -43,7 +42,8 @@ exports.default = async (type) => {
43
42
  message: `${invalidMessage} Select dataverse project to create?`,
44
43
  choices: [
45
44
  { title: 'web resource', value: 'webresource' },
46
- { title: 'plugin or workflow activity', value: 'assembly' }
45
+ { title: 'plugin or workflow activity', value: 'assembly' },
46
+ { title: 'powerapps component framework control', value: 'pcf' }
47
47
  ]
48
48
  });
49
49
  type = promptType;
@@ -54,20 +54,51 @@ exports.default = async (type) => {
54
54
  const xrmVersions = await (0, nuget_1.getNugetPackageVersions)('JourneyTeam.Xrm');
55
55
  config.xrmVersion = xrmVersions.shift();
56
56
  }
57
- console.info(kleur_1.default.green(`${kleur_1.default.green(tick)} get plop generator`));
57
+ logger_1.logger.info('get plop generator');
58
58
  const generator = await (0, plop_1.getGenerator)(type, name);
59
- console.info(`${kleur_1.default.green(tick)} run powerapps-project-${type} code generator`);
59
+ logger_1.logger.info(`run powerapps-project-${type} code generator`);
60
60
  await (0, plop_1.runGenerator)(generator, config);
61
- console.info(`${kleur_1.default.green(tick)} initialize project`);
62
- pkg.install(process.cwd(), type);
61
+ logger_1.logger.info('initialize project');
62
+ if (type !== 'pcf' || config.react) {
63
+ pkg.install(process.cwd(), type);
64
+ }
63
65
  if (type === 'assembly') {
64
- console.info(`${kleur_1.default.green(tick)} add nuget packages`);
66
+ logger_1.logger.info('add nuget packages');
65
67
  (0, nuget_1.install)(config.name, config.sdkVersion, config.xrmVersion);
66
68
  }
67
69
  (0, exports.done)(type);
68
70
  };
69
71
  const getAnswers = async (type) => {
70
72
  let questions = [];
73
+ if (type === 'pcf') {
74
+ questions = [
75
+ {
76
+ type: 'select',
77
+ name: 'template',
78
+ message: 'template',
79
+ choices: [
80
+ { title: 'field', value: 'field' },
81
+ { title: 'dataset', value: 'dataset' }
82
+ ]
83
+ },
84
+ {
85
+ type: 'text',
86
+ name: 'namespace',
87
+ message: 'namespace'
88
+ },
89
+ {
90
+ type: 'text',
91
+ name: 'name',
92
+ message: 'name'
93
+ },
94
+ {
95
+ type: 'confirm',
96
+ name: 'react',
97
+ message: 'install react?'
98
+ }
99
+ ];
100
+ return questions;
101
+ }
71
102
  if (type === 'webresource') {
72
103
  questions.push({
73
104
  type: 'text',
@@ -128,30 +159,54 @@ const getAnswers = async (type) => {
128
159
  return questions;
129
160
  };
130
161
  const done = (type) => {
131
- const message = `
162
+ if (process.env.JEST_WORKER_ID !== undefined) {
163
+ return;
164
+ }
165
+ let message;
166
+ if (type === 'pcf') {
167
+ message = `
132
168
 
133
- ${kleur_1.default.green(tick)} ${type} project created!
169
+ ${logger_1.icons.done} ${type} project created!
134
170
 
135
171
  keep your build tools up-to-date by updating these two devDependencies:
136
- ${kleur_1.default.cyan(pointer)} dataverse-utils
137
- ${kleur_1.default.cyan(pointer)} powerapps-project-${type}
172
+ ${logger_1.icons.info} powerapps-project-${type}
173
+
174
+ build your project in watch mode with this command:
175
+ ${logger_1.icons.info} npm start watch
176
+ build your project in production mode with this command:
177
+ ${logger_1.icons.info} npm run build
178
+
179
+ run code generator with this command:
180
+ ${logger_1.icons.info} npm run gen
181
+
182
+ `;
183
+ }
184
+ else {
185
+ message = `
186
+
187
+ ${logger_1.icons.done} ${type} project created!
188
+
189
+ keep your build tools up-to-date by updating these two devDependencies:
190
+ ${logger_1.icons.info} dataverse-utils
191
+ ${logger_1.icons.info} powerapps-project-${type}
138
192
 
139
193
  ${type === 'webresource' ?
140
- `build your project in watch mode with this command:
141
- ${kleur_1.default.cyan(pointer)} ${pkg.getYarn() ? 'yarn' : 'npm run'} start
194
+ `build your project in watch mode with this command:
195
+ ${logger_1.icons.info} ${pkg.getYarn() ? 'yarn' : 'npm run'} start
142
196
  build your project in production mode with this command:
143
- ${kleur_1.default.cyan(pointer)} ${pkg.getYarn() ? 'yarn' : 'npm run'} build
197
+ ${logger_1.icons.info} ${pkg.getYarn() ? 'yarn' : 'npm run'} build
144
198
  generate table definition files with this command:
145
- ${kleur_1.default.cyan(pointer)} ${pkg.getYarn() ? 'yarn' : 'npm run'} generate` :
146
- `build your project with this command:
199
+ ${logger_1.icons.info} ${pkg.getYarn() ? 'yarn' : 'npm run'} generate` :
200
+ `build your project with this command:
147
201
  dotnet build
148
202
  deploy your project with this command:
149
- ${kleur_1.default.cyan(pointer)} ${pkg.getYarn() ? 'yarn' : 'npm run'} deploy`}
203
+ ${logger_1.icons.info} ${pkg.getYarn() ? 'yarn' : 'npm run'} deploy`}
150
204
 
151
205
  run code generator with this command:
152
- ${kleur_1.default.cyan(pointer)} ${pkg.getYarn() ? 'yarn' : 'npm run'} gen
206
+ ${logger_1.icons.info} ${pkg.getYarn() ? 'yarn' : 'npm run'} gen
153
207
 
154
208
  `;
209
+ }
155
210
  console.info(message);
156
211
  };
157
212
  exports.done = done;
@@ -47,6 +47,9 @@ const install = (project, sdkVersion, xrmVersion) => {
47
47
  cwd: process.cwd(),
48
48
  stdio: 'inherit'
49
49
  });
50
+ if (process.env.JEST_WORKER_ID !== undefined) {
51
+ return;
52
+ }
50
53
  (0, child_process_1.spawnSync)('dotnet', ['restore'], {
51
54
  cwd: process.cwd(),
52
55
  stdio: 'inherit'
@@ -15,6 +15,9 @@ const getNpm = () => {
15
15
  };
16
16
  const install = (cwd, type) => {
17
17
  const packages = getPackages(type);
18
+ if (process.env.JEST_WORKER_ID !== undefined) {
19
+ return;
20
+ }
18
21
  if ((0, exports.getYarn)()) {
19
22
  (0, child_process_1.spawnSync)((0, exports.getYarn)(), ['add', ...packages.devDependencies], { stdio: 'inherit', cwd });
20
23
  if (packages.dependencies) {
@@ -30,6 +33,20 @@ const install = (cwd, type) => {
30
33
  };
31
34
  exports.install = install;
32
35
  function getPackages(type) {
36
+ if (type === 'pcf') {
37
+ return {
38
+ dependencies: [
39
+ 'react',
40
+ 'react-dom',
41
+ '@fluentui/react'
42
+ ],
43
+ devDependencies: [
44
+ `powerapps-project-${type}`,
45
+ '@types/react',
46
+ '@types/react-dom'
47
+ ]
48
+ };
49
+ }
33
50
  const packages = {
34
51
  devDependencies: [
35
52
  `powerapps-project-${type}`,
@@ -6,11 +6,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.runGenerator = exports.getGenerator = void 0;
7
7
  const node_plop_1 = __importDefault(require("node-plop"));
8
8
  const path_1 = __importDefault(require("path"));
9
- const tick = '√';
9
+ const logger_1 = require("../../../logger");
10
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
11
  const getGenerator = async (type, name) => {
12
- const plopFile = path_1.default.resolve(__dirname, 'plopfile.js');
13
- const plop = await (0, node_plop_1.default)(plopFile, { destBasePath: name, force: false });
12
+ let plopFile = path_1.default.resolve(__dirname, 'plopfile.js');
13
+ if (process.env.JEST_WORKER_ID !== undefined) {
14
+ plopFile = path_1.default.resolve(__dirname, 'plopfile.ts');
15
+ }
16
+ const plop = (0, node_plop_1.default)(plopFile, { destBasePath: name, force: false });
14
17
  const generator = plop.getGenerator(type);
15
18
  return generator;
16
19
  };
@@ -18,7 +21,7 @@ exports.getGenerator = getGenerator;
18
21
  const runGenerator = async (generator, args) => {
19
22
  const results = await generator.runActions(args, {
20
23
  onComment: (comment) => {
21
- console.log(`${tick} ${comment}`);
24
+ logger_1.logger.done(comment);
22
25
  }
23
26
  });
24
27
  if (results.failures && results.failures.length > 0) {
@@ -27,7 +30,7 @@ const runGenerator = async (generator, args) => {
27
30
  // do something after the actions have run
28
31
  for (const change of results.changes) {
29
32
  if (change.path) {
30
- console.log(`${tick} ${change.path}`);
33
+ logger_1.logger.done(change.path);
31
34
  }
32
35
  }
33
36
  };
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const path_1 = __importDefault(require("path"));
7
7
  const child_process_1 = require("child_process");
8
+ const fs_1 = __importDefault(require("fs"));
8
9
  /* eslint-disable @typescript-eslint/no-explicit-any */
9
10
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
10
11
  exports.default = (plop) => {
@@ -13,6 +14,26 @@ exports.default = (plop) => {
13
14
  (0, child_process_1.spawnSync)(path_1.default.resolve(__dirname, '../', 'bin', 'sn.exe'), ['-q', '-k', keyPath], { stdio: 'inherit' });
14
15
  return 'signed assembly';
15
16
  });
17
+ plop.setActionType('runPcf', (answers) => {
18
+ const args = ['pcf', 'init', '-ns', answers.namespace, '-n', answers.name, '-t', answers.template];
19
+ /// Setting framework to React currently unsupported by PCF CLI
20
+ // if (answers.react) {
21
+ // args.push('-fw', 'react');
22
+ // }
23
+ if (process.env.JEST_WORKER_ID !== undefined) {
24
+ args.push('-npm', 'false');
25
+ }
26
+ (0, child_process_1.spawnSync)('pac', args, { stdio: 'inherit' });
27
+ return 'pcf project created';
28
+ });
29
+ plop.setActionType('addGenScript', () => {
30
+ const packagePath = path_1.default.resolve(process.cwd(), 'package.json');
31
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
32
+ const packageJson = require(packagePath);
33
+ packageJson.scripts.gen = 'plop';
34
+ fs_1.default.writeFileSync(packagePath, JSON.stringify(packageJson, null, 4), 'utf8');
35
+ return 'added plop script to package.json';
36
+ });
16
37
  plop.setGenerator('webresource', {
17
38
  actions: [
18
39
  {
@@ -24,6 +45,32 @@ exports.default = (plop) => {
24
45
  }
25
46
  ]
26
47
  });
48
+ plop.setGenerator('pcf', {
49
+ actions: [
50
+ {
51
+ type: 'runPcf'
52
+ },
53
+ {
54
+ type: 'addMany',
55
+ templateFiles: [
56
+ '../plop-templates/pcf/App.tsx',
57
+ '../plop-templates/pcf/index.ts'
58
+ ],
59
+ base: '../plop-templates/pcf',
60
+ destination: `${process.cwd()}/{{ name }}`,
61
+ force: true,
62
+ skip: (answers) => {
63
+ return !answers.react;
64
+ }
65
+ },
66
+ {
67
+ type: 'addGenScript',
68
+ skip: (answers) => {
69
+ return !answers.react;
70
+ }
71
+ }
72
+ ]
73
+ });
27
74
  plop.setGenerator('assembly', {
28
75
  actions: [
29
76
  {
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.15.6",
4
+ "version": "0.16.0",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
7
7
  "bin": {
@@ -19,14 +19,14 @@
19
19
  "scripts": {
20
20
  "build": "tsc -p .",
21
21
  "lint": "eslint",
22
- "prebuild": "rimraf lib"
22
+ "clean": "rimraf lib"
23
23
  },
24
24
  "dependencies": {
25
+ "commander": "^8.3.0",
25
26
  "envinfo": "^7.8.1",
27
+ "kleur": "^4.1.4",
26
28
  "node-plop": "^0.26.3",
27
- "prompts": "^2.4.2",
28
- "commander": "^8.3.0",
29
- "kleur": "^4.1.4"
29
+ "prompts": "^2.4.2"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/envinfo": "^7.8.1",
@@ -0,0 +1,20 @@
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
+
@@ -0,0 +1,66 @@
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 } from './App';
7
+
8
+ export class ReportDashboard implements ComponentFramework.StandardControl<IInputs, IOutputs> {
9
+ container: HTMLDivElement;
10
+ context: ComponentFramework.Context<IInputs>;
11
+ isTestHarness: boolean;
12
+
13
+ /**
14
+ * Empty constructor.
15
+ */
16
+ constructor() {
17
+
18
+ }
19
+
20
+ /**
21
+ * Used to initialize the control instance. Controls can kick off remote server calls and other initialization actions here.
22
+ * Data-set values are not initialized here, use updateView.
23
+ * @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.
24
+ * @param notifyOutputChanged A callback method to alert the framework that the control has new outputs ready to be retrieved asynchronously.
25
+ * @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.
26
+ * @param container If a control is marked control-type='standard', it will receive an empty div element within which it can render its content.
27
+ */
28
+ public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container: HTMLDivElement): void {
29
+ initializeIcons(undefined, { disableWarnings: true });
30
+
31
+ this.container = container;
32
+ this.context = context;
33
+ this.isTestHarness = document.getElementById('control-dimensions') !== null;
34
+ }
35
+
36
+
37
+ /**
38
+ * 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.
39
+ * @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
40
+ */
41
+ public updateView(context: ComponentFramework.Context<IInputs>): void {
42
+ ReactDOM.render(
43
+ React.createElement(App, {
44
+ isTestHarness: this.isTestHarness
45
+ }),
46
+ this.container
47
+ );
48
+ }
49
+
50
+ /**
51
+ * It is called by the framework prior to a control receiving new data.
52
+ * @returns an object based on nomenclature defined in manifest, expecting object[s] for property marked as “bound” or “output”
53
+ */
54
+ public getOutputs(): IOutputs {
55
+ return {};
56
+ }
57
+
58
+ /**
59
+ * Called when the control is to be removed from the DOM tree. Controls should use this call for cleanup.
60
+ * i.e. cancelling any pending remote calls, removing listeners, etc.
61
+ */
62
+ public destroy(): void {
63
+ // Add code to cleanup control if necessary
64
+ }
65
+
66
+ }
@@ -1,12 +0,0 @@
1
- export interface Config {
2
- name: string;
3
- isolation: number;
4
- tenant: string;
5
- solution: string;
6
- server: string;
7
- xrmVersion?: string;
8
- sdkVersion?: string;
9
- }
10
- declare const _default: (type: string) => Promise<void>;
11
- export default _default;
12
- export declare const done: (type: string) => void;
@@ -1,11 +0,0 @@
1
- export interface EnvInfoCache {
2
- Binaries: {
3
- Yarn: any;
4
- npm: any;
5
- };
6
- npmGlobalPackages: {
7
- pnpm: any;
8
- };
9
- }
10
- export declare const getEnvInfo: () => EnvInfoCache;
11
- export declare const initialize: () => Promise<any>;
package/lib/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/lib/logger.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export declare const logger: {
2
- info(...args: any[]): void;
3
- warn(...args: any[]): void;
4
- error(...args: any[]): void;
5
- };
package/lib/nuget.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const getNugetPackageVersions: (name: string) => Promise<string[]>;
2
- export declare const install: (project: string, sdkVersion?: string | undefined, xrmVersion?: string | undefined) => void;
@@ -1,2 +0,0 @@
1
- export declare const getYarn: () => any;
2
- export declare const install: (cwd: string, type: string) => void;
package/lib/plop.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { PlopGenerator } from 'node-plop';
2
- import { Config } from './createDataverseProject';
3
- export declare const getGenerator: (type: string, name: string) => Promise<PlopGenerator>;
4
- export declare const runGenerator: (generator: PlopGenerator, args: Config) => Promise<void>;
package/lib/plopfile.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare const _default: (plop: any) => void;
2
- export default _default;