create-powerapps-project 0.20.0 → 0.21.2

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 CHANGED
@@ -1,18 +1,13 @@
1
1
  #!/usr/bin/env node
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({
2
+ import path from 'node:path';
3
+ import { Plop, run } from 'plop';
4
+ Plop.launch({
10
5
  cwd: process.cwd(),
11
- configPath: node_path_1.default.join(__dirname, 'plopfile.js')
6
+ configPath: path.join(__dirname, 'plopfile.js')
12
7
  }, env => {
13
8
  const options = {
14
9
  ...env,
15
10
  dest: process.cwd() // this will make the destination path to be based on the cwd when calling the wrapper
16
11
  };
17
- return (0, plop_1.run)(options, undefined, true);
12
+ return run(options, undefined, true);
18
13
  });
package/lib/nuget.js CHANGED
@@ -1,14 +1,8 @@
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) => {
1
+ import https from 'https';
2
+ import { spawnSync } from 'child_process';
3
+ export const getNugetPackageVersions = (name) => {
10
4
  return new Promise((resolve, reject) => {
11
- https_1.default.get(`https://azuresearch-usnc.nuget.org/query?q=packageid:${name}`, (response) => {
5
+ https.get(`https://azuresearch-usnc.nuget.org/query?q=packageid:${name}`, (response) => {
12
6
  let body = '';
13
7
  response.on('data', (d) => {
14
8
  body += d;
@@ -25,32 +19,30 @@ const getNugetPackageVersions = (name) => {
25
19
  });
26
20
  });
27
21
  };
28
- exports.getNugetPackageVersions = getNugetPackageVersions;
29
- const install = (project, sdkVersion, xrmVersion) => {
22
+ export const install = (project, sdkVersion, xrmVersion) => {
30
23
  // Add solution
31
- (0, child_process_1.spawnSync)('dotnet', ['new', 'sln', '-n', project], {
24
+ spawnSync('dotnet', ['new', 'sln', '-n', project], {
32
25
  cwd: process.cwd(),
33
26
  stdio: 'inherit'
34
27
  });
35
- (0, child_process_1.spawnSync)('dotnet', ['sln', 'add', `${project}.csproj`], {
28
+ spawnSync('dotnet', ['sln', 'add', `${project}.csproj`], {
36
29
  cwd: process.cwd(),
37
30
  stdio: 'inherit'
38
31
  });
39
32
  // Install nuget packages
40
- (0, child_process_1.spawnSync)('dotnet', ['add', 'package', 'Microsoft.CrmSdk.Workflow', '-v', sdkVersion, '-n'], {
33
+ spawnSync('dotnet', ['add', 'package', 'Microsoft.CrmSdk.Workflow', '-v', sdkVersion, '-n'], {
41
34
  cwd: process.cwd(),
42
35
  stdio: 'inherit'
43
36
  });
44
- (0, child_process_1.spawnSync)('dotnet', ['add', 'package', 'JourneyTeam.Xrm', '-v', xrmVersion, '-n'], {
37
+ spawnSync('dotnet', ['add', 'package', 'JourneyTeam.Xrm', '-v', xrmVersion, '-n'], {
45
38
  cwd: process.cwd(),
46
39
  stdio: 'inherit'
47
40
  });
48
41
  if (process.env.JEST_WORKER_ID !== undefined) {
49
42
  return;
50
43
  }
51
- (0, child_process_1.spawnSync)('dotnet', ['restore'], {
44
+ spawnSync('dotnet', ['restore'], {
52
45
  cwd: process.cwd(),
53
46
  stdio: 'inherit'
54
47
  });
55
48
  };
56
- exports.install = install;
@@ -1,55 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.install = exports.getYarn = void 0;
4
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
5
- const child_process_1 = require("child_process");
6
- const getEnvInfo_1 = require("./getEnvInfo");
7
- const getYarn = () => {
8
- const yarnInfo = (0, getEnvInfo_1.getEnvInfo)().Binaries.Yarn;
9
- return yarnInfo && yarnInfo.path;
10
- };
11
- exports.getYarn = getYarn;
12
- const getNpm = () => {
13
- const npmInfo = (0, getEnvInfo_1.getEnvInfo)().Binaries.npm;
14
- return npmInfo && npmInfo.path;
15
- };
16
- const install = (cwd, type) => {
17
- const packages = getPackages(type);
18
- if (process.env.JEST_WORKER_ID !== undefined) {
2
+ import { spawnSync } from 'child_process';
3
+ export const install = (cwd, type, packageManager) => {
4
+ if (process.env.JEST_WORKER_ID != undefined) {
19
5
  return;
20
6
  }
21
- if ((0, exports.getYarn)()) {
22
- (0, child_process_1.spawnSync)((0, exports.getYarn)(), ['add', ...packages.devDependencies], { stdio: 'inherit', cwd });
23
- if (packages.dependencies) {
24
- (0, child_process_1.spawnSync)((0, exports.getYarn)(), ['add', ...packages.dependencies], { stdio: 'inherit', cwd });
25
- }
7
+ if (type === 'pcf') {
8
+ spawnSync(packageManager, ['install'], { stdio: 'inherit', shell: true });
26
9
  }
27
10
  else {
28
- (0, child_process_1.spawnSync)(getNpm(), ['install', ...packages.devDependencies], { stdio: 'inherit', cwd });
11
+ const packages = getPackages(type);
12
+ spawnSync(packageManager, ['add', ...packages.devDependencies], { stdio: 'inherit', shell: true });
29
13
  if (packages.dependencies) {
30
- (0, child_process_1.spawnSync)(getNpm(), ['install', ...packages.dependencies], { stdio: 'inherit', cwd });
14
+ spawnSync(packageManager, ['add', ...packages.dependencies], { stdio: 'inherit', shell: true });
31
15
  }
32
16
  }
33
17
  };
34
- exports.install = install;
35
18
  function getPackages(type) {
36
- if (type === 'pcf') {
37
- return {
38
- dependencies: [
39
- 'react@17.0.2',
40
- 'react-dom@17.0.2',
41
- '@fluentui/react',
42
- '@fluentui/font-icons-mdl2'
43
- ],
44
- devDependencies: [
45
- //`powerapps-project-${type}`,
46
- '@types/react@17.0.39',
47
- '@types/react-dom@17.0.11',
48
- '@types/xrm',
49
- '-D'
50
- ]
51
- };
52
- }
53
19
  const packages = {
54
20
  devDependencies: [
55
21
  `powerapps-project-${type}`,
package/lib/plopfile.js CHANGED
@@ -1,102 +1,26 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- const path_1 = __importDefault(require("path"));
26
- const child_process_1 = require("child_process");
27
- const fs_1 = __importDefault(require("fs"));
28
- const nuget = __importStar(require("./nuget"));
29
- const pkg = __importStar(require("./packageManager"));
30
- const getEnvInfo_1 = require("./getEnvInfo");
1
+ import path from 'path';
2
+ import { spawn } from 'child_process';
3
+ import fs from 'fs';
4
+ import * as nuget from './nuget';
5
+ import * as pkg from './packageManager';
31
6
  const didSucceed = (code) => `${code}` === '0';
7
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
8
+ const version = require('../package').version;
32
9
  /* eslint-disable @typescript-eslint/no-explicit-any */
33
- exports.default = (plop) => {
34
- void (0, getEnvInfo_1.initialize)();
35
- plop.setActionType('signAssembly', (answers) => {
36
- const keyPath = path_1.default.resolve(process.cwd(), `${answers.name}.snk`);
37
- return new Promise((resolve, reject) => {
38
- if (process.env.JEST_WORKER_ID !== undefined) {
39
- resolve('Testing so no need to sign');
40
- }
41
- const sign = (0, child_process_1.spawn)(path_1.default.resolve(__dirname, '../', 'bin', 'sn.exe'), ['-q', '-k', keyPath], { stdio: 'inherit' });
42
- sign.on('close', (code) => {
43
- if (didSucceed(code)) {
44
- resolve('signed assembly');
45
- }
46
- else {
47
- reject('failed to sign assembly');
48
- }
49
- });
50
- sign.on('error', () => {
51
- reject('failed to sign assembly');
52
- });
53
- });
54
- });
55
- plop.setActionType('runPcf', (answers) => {
56
- const args = ['pcf', 'init', '-ns', answers.namespace, '-n', answers.name, '-t', answers.template];
57
- /// Setting framework to React currently unsupported by PCF CLI
58
- // if (answers.react) {
59
- // args.push('-fw', 'react');
60
- // }
61
- if (process.env.JEST_WORKER_ID !== undefined) {
62
- args.push('-npm', 'false');
63
- }
64
- return new Promise((resolve, reject) => {
65
- const pac = (0, child_process_1.spawn)('pac', args, { stdio: 'inherit' });
66
- pac.on('close', (code) => {
67
- if (didSucceed(code)) {
68
- resolve('pcf project created');
69
- }
70
- else {
71
- reject('Ensure the Power Platform CLI is installed. Command must be run from within VS Code if using the Power Platform Extension');
72
- }
73
- });
74
- pac.on('error', () => {
75
- reject('Ensure the Power Platform CLI is installed. Command must be run from within VS Code if using the Power Platform Extension');
76
- });
77
- });
78
- });
79
- plop.setActionType('addGenScript', async () => {
80
- const packagePath = path_1.default.resolve(process.cwd(), 'package.json');
81
- // eslint-disable-next-line @typescript-eslint/no-var-requires
82
- const packageJson = require(packagePath);
83
- packageJson.scripts.gen = 'plop';
84
- await fs_1.default.promises.writeFile(packagePath, JSON.stringify(packageJson, null, 4), 'utf8');
85
- return 'added plop script to package.json';
86
- });
87
- plop.setActionType('nugetInstall', async (answers) => {
88
- const xrmVersions = await nuget.getNugetPackageVersions('JourneyTeam.Xrm');
89
- const xrmVersion = xrmVersions.shift();
90
- nuget.install(answers.name, answers.sdkVersion, xrmVersion);
91
- return 'installed nuget packages';
92
- });
93
- plop.setActionType('npmInstall', (answers) => {
94
- if (answers.projectType) {
95
- pkg.install(process.cwd(), answers.projectType);
96
- }
97
- return 'installed npm packages';
98
- });
99
- const connectionQuestions = [
10
+ export default (plop) => {
11
+ plop.setWelcomeMessage(`Creating new Dataverse project using create-powerapps-project v${version}. Please choose type of project to create.`);
12
+ const packageQuestion = {
13
+ type: 'list',
14
+ name: 'package',
15
+ message: 'package manager (ensure selected option is installed)',
16
+ choices: [
17
+ { name: 'npm', value: 'npm' },
18
+ { name: 'pnpm', value: 'pnpm' },
19
+ { name: 'yarn', value: 'yarn' }
20
+ ],
21
+ default: 'npm'
22
+ };
23
+ const sharedQuestions = [
100
24
  {
101
25
  type: 'input',
102
26
  name: 'server',
@@ -114,6 +38,18 @@ exports.default = (plop) => {
114
38
  message: 'dataverse solution unique name:'
115
39
  }
116
40
  ];
41
+ plop.setActionType('addScript', async (answers) => {
42
+ const packagePath = path.resolve(process.cwd(), 'package.json');
43
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
44
+ const packageJson = require(packagePath);
45
+ packageJson.scripts[answers.scriptKey] = answers.scriptValue;
46
+ await fs.promises.writeFile(packagePath, JSON.stringify(packageJson, null, 4), 'utf8');
47
+ return `added ${answers.scriptKey} script to package.json`;
48
+ });
49
+ plop.setActionType('npmInstall', (answers) => {
50
+ pkg.install(process.cwd(), answers.projectType, answers.package);
51
+ return 'installed npm packages';
52
+ });
117
53
  plop.setGenerator('assembly', {
118
54
  description: 'generate dataverse assembly project',
119
55
  prompts: [
@@ -129,7 +65,20 @@ exports.default = (plop) => {
129
65
  {
130
66
  type: 'input',
131
67
  name: 'name',
132
- message: 'default C# namespace (Company.Crm.Plugins):'
68
+ message: 'default C# namespace (Company.Crm.Plugins):',
69
+ validate: (name) => {
70
+ const namespace = name.split('.');
71
+ if (namespace.length !== 3) {
72
+ return `enter namespace using 'Company.Crm.Plugins' convention`;
73
+ }
74
+ for (const item of namespace) {
75
+ const title = plop.renderString('{{titleCase name}}', { name: item });
76
+ if (title !== item) {
77
+ return `enter namespace using pascal case (Company.Crm.Plugins)`;
78
+ }
79
+ }
80
+ return true;
81
+ }
133
82
  },
134
83
  {
135
84
  type: 'list',
@@ -147,13 +96,14 @@ exports.default = (plop) => {
147
96
  }
148
97
  ]
149
98
  },
150
- ...connectionQuestions,
99
+ packageQuestion,
100
+ ...sharedQuestions,
151
101
  ],
152
102
  actions: [
153
103
  {
154
104
  type: 'add',
155
105
  templateFile: '../plop-templates/assembly/assembly.csproj.hbs',
156
- path: path_1.default.resolve(process.cwd(), '{{name}}.csproj'),
106
+ path: path.resolve(process.cwd(), '{{name}}.csproj'),
157
107
  },
158
108
  {
159
109
  type: 'addMany',
@@ -170,11 +120,33 @@ exports.default = (plop) => {
170
120
  destination: process.cwd(),
171
121
  force: true
172
122
  },
173
- {
174
- type: 'signAssembly'
123
+ (answers) => {
124
+ const keyPath = path.resolve(process.cwd(), `${answers.name}.snk`);
125
+ return new Promise((resolve, reject) => {
126
+ if (process.env.JEST_WORKER_ID !== undefined) {
127
+ resolve('Testing so no need to sign');
128
+ }
129
+ else {
130
+ const sign = spawn(path.resolve(__dirname, '..', 'bin', 'sn.exe'), ['-q', '-k', keyPath], { stdio: 'inherit' });
131
+ sign.on('close', (code) => {
132
+ if (didSucceed(code)) {
133
+ resolve('signed assembly');
134
+ }
135
+ else {
136
+ reject('failed to sign assembly');
137
+ }
138
+ });
139
+ sign.on('error', () => {
140
+ reject('failed to sign assembly');
141
+ });
142
+ }
143
+ });
175
144
  },
176
- {
177
- type: 'nugetInstall'
145
+ async (answers) => {
146
+ const xrmVersions = await nuget.getNugetPackageVersions('JourneyTeam.Xrm');
147
+ const xrmVersion = xrmVersions.shift();
148
+ nuget.install(answers.name, answers.sdkVersion, xrmVersion);
149
+ return 'installed nuget packages';
178
150
  },
179
151
  {
180
152
  type: 'npmInstall',
@@ -210,21 +182,51 @@ exports.default = (plop) => {
210
182
  type: 'confirm',
211
183
  name: 'react',
212
184
  message: 'use react?'
213
- }
185
+ },
186
+ packageQuestion
214
187
  ],
215
188
  actions: [
189
+ (answers) => {
190
+ const args = ['pcf', 'init', '-ns', answers.namespace, '-n', answers.name, '-t', answers.template];
191
+ // Set framework to React if selected
192
+ if (answers.react) {
193
+ args.push('-fw', 'react');
194
+ }
195
+ if (process.env.JEST_WORKER_ID !== undefined || answers.package !== 'npm') {
196
+ args.push('-npm', 'false');
197
+ }
198
+ else {
199
+ args.push('-npm', 'true');
200
+ }
201
+ return new Promise((resolve, reject) => {
202
+ const pac = spawn('pac', args, { stdio: 'inherit' });
203
+ pac.on('close', (code) => {
204
+ if (didSucceed(code)) {
205
+ resolve('pcf project created');
206
+ }
207
+ else {
208
+ reject('Ensure the Power Platform CLI is installed. Command must be run from within Visual Studio Code if using the Power Platform Extension');
209
+ }
210
+ });
211
+ pac.on('error', () => {
212
+ reject('Ensure the Power Platform CLI is installed. Command must be run from within Visual Studio Code if using the Power Platform Extension');
213
+ });
214
+ });
215
+ },
216
216
  {
217
- type: 'runPcf'
217
+ type: 'add',
218
+ templateFile: '../plop-templates/pcf/tsconfig.json',
219
+ path: path.resolve(process.cwd(), 'tsconfig.json'),
220
+ force: true
218
221
  },
219
222
  {
220
223
  type: 'addMany',
221
224
  templateFiles: [
222
- '../plop-templates/pcf/App.tsx',
223
- '../plop-templates/pcf/index.ts.hbs'
225
+ '../plop-templates/pcf/App.tsx.hbs',
226
+ '../plop-templates/pcf/AppContext.ts'
224
227
  ],
225
228
  base: '../plop-templates/pcf',
226
229
  destination: `${process.cwd()}/{{ name }}`,
227
- force: true,
228
230
  skip: (answers) => {
229
231
  if (!answers.react) {
230
232
  return 'react not included';
@@ -233,27 +235,43 @@ exports.default = (plop) => {
233
235
  }
234
236
  },
235
237
  {
236
- type: 'add',
237
- templateFile: '../plop-templates/pcf/tsconfig.json',
238
- path: path_1.default.resolve(process.cwd(), 'tsconfig.json'),
239
- force: true,
240
- skip: (answers) => {
241
- if (!answers.react) {
242
- return 'react not included';
243
- }
244
- return;
238
+ type: 'modify',
239
+ path: `${process.cwd()}/{{ name }}/index.ts`,
240
+ pattern: 'import { HelloWorld, IHelloWorldProps } from "./HelloWorld";',
241
+ template: `import { App, IAppProps } from './App';`
242
+ },
243
+ {
244
+ type: 'modify',
245
+ path: `${process.cwd()}/{{ name }}/index.ts`,
246
+ pattern: 'HelloWorld, props',
247
+ template: 'App, props'
248
+ },
249
+ {
250
+ type: 'modify',
251
+ path: `${process.cwd()}/{{ name }}/index.ts`,
252
+ pattern: `const props: IHelloWorldProps = { name: 'Hello, World!' };`,
253
+ template: `const props: IAppProps = { context: context };`
254
+ },
255
+ {
256
+ type: 'addScript',
257
+ data: {
258
+ scriptKey: 'build:prod',
259
+ scriptValue: 'pcf-scripts build --buildMode production'
245
260
  }
246
261
  },
262
+ async (answers) => {
263
+ await fs.promises.rm(path.resolve(process.cwd(), answers.name, 'HelloWorld.tsx'));
264
+ return 'removed HelloWorld component';
265
+ },
247
266
  {
248
267
  type: 'npmInstall',
249
268
  data: {
250
269
  projectType: 'pcf'
251
270
  },
252
271
  skip: (answers) => {
253
- if (!answers.react) {
254
- return 'react not included';
272
+ if (answers.package === 'npm') {
273
+ return 'npm packages already installed';
255
274
  }
256
- return;
257
275
  }
258
276
  }
259
277
  ]
@@ -265,14 +283,15 @@ exports.default = (plop) => {
265
283
  type: 'input',
266
284
  name: 'name',
267
285
  message: 'project name',
268
- default: path_1.default.basename(process.cwd())
286
+ default: path.basename(process.cwd())
269
287
  },
270
288
  {
271
289
  type: 'input',
272
290
  name: 'namespace',
273
291
  message: 'namespace for form and ribbon scripts:'
274
292
  },
275
- ...connectionQuestions
293
+ packageQuestion,
294
+ ...sharedQuestions
276
295
  ],
277
296
  actions: [
278
297
  {
@@ -281,6 +300,12 @@ exports.default = (plop) => {
281
300
  base: '../plop-templates/webresource',
282
301
  destination: process.cwd(),
283
302
  force: true
303
+ },
304
+ {
305
+ type: 'npmInstall',
306
+ data: {
307
+ projectType: 'webresource'
308
+ }
284
309
  }
285
310
  ]
286
311
  });
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "create-powerapps-project",
3
3
  "description": "💧 plop generator for Dataverse development",
4
- "version": "0.20.0",
4
+ "version": "0.21.2",
5
5
  "license": "MIT",
6
- "type": "commonjs",
7
6
  "main": "lib/index.js",
8
7
  "bin": {
9
8
  "create-powerapps-project": "lib/index.js"
@@ -23,11 +22,9 @@
23
22
  "clean": "rimraf lib"
24
23
  },
25
24
  "dependencies": {
26
- "envinfo": "^7.8.1",
27
25
  "plop": "^2.7.6"
28
26
  },
29
27
  "devDependencies": {
30
- "@types/envinfo": "^7.8.1",
31
28
  "@types/node": "^14.14.21"
32
29
  }
33
30
  }
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { IInputs } from './generated/ManifestTypes';
3
+ import AppContext from './AppContext';
4
+
5
+ export interface IAppProps {
6
+ context: ComponentFramework.Context<IInputs>;
7
+ }
8
+
9
+ export const App = React.memo((props: IAppProps) => {
10
+ const {
11
+ context,
12
+ } = props;
13
+
14
+ return (
15
+ <AppContext.Provider value=\{{ context: context }}>
16
+ </AppContext.Provider>
17
+ );
18
+ });
19
+
20
+ App.displayName = 'App';
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { IInputs } from './generated/ManifestTypes';
3
+
4
+ interface IAppContext {
5
+ context: ComponentFramework.Context<IInputs>;
6
+ }
7
+
8
+ const AppContext = React.createContext<IAppContext>({} as IAppContext);
9
+
10
+ export default AppContext;
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "extends": "./node_modules/pcf-scripts/tsconfig_base.json",
3
3
  "compilerOptions": {
4
- "target": "ES6",
5
- "esModuleInterop": true
4
+ "typeRoots": ["node_modules/@types"],
5
+ "esModuleInterop": true,
6
+ "target": "ES6"
6
7
  }
7
8
  }
@@ -3,6 +3,7 @@ module.exports = {
3
3
  parser: '@typescript-eslint/parser',
4
4
  plugins: [
5
5
  '@typescript-eslint',
6
+ "@microsoft/power-apps"
6
7
  ],
7
8
  extends: [
8
9
  'eslint:recommended',
package/lib/getEnvInfo.js DELETED
@@ -1,33 +0,0 @@
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.initialize = exports.getEnvInfo = void 0;
7
- /* eslint-disable @typescript-eslint/no-explicit-any */
8
- const envinfo_1 = __importDefault(require("envinfo"));
9
- const os_1 = __importDefault(require("os"));
10
- const path_1 = __importDefault(require("path"));
11
- let envInfoCache;
12
- const getEnvInfo = () => {
13
- return envInfoCache;
14
- };
15
- exports.getEnvInfo = getEnvInfo;
16
- const initialize = async () => {
17
- envInfoCache = JSON.parse(await envinfo_1.default.run({
18
- Binaries: ['Yarn', 'npm']
19
- }, { json: true, showNotFound: false }));
20
- if (envInfoCache.Binaries.Yarn) {
21
- envInfoCache.Binaries.Yarn.path = expandHome(envInfoCache.Binaries.Yarn.path);
22
- }
23
- if (envInfoCache.Binaries.npm) {
24
- envInfoCache.Binaries.npm.path = expandHome(envInfoCache.Binaries.npm.path);
25
- }
26
- };
27
- exports.initialize = initialize;
28
- const expandHome = (pathString) => {
29
- if (pathString.startsWith('~' + path_1.default.sep)) {
30
- return pathString.replace('~', os_1.default.homedir());
31
- }
32
- return pathString;
33
- };
@@ -1,20 +0,0 @@
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
-
@@ -1,70 +0,0 @@
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, AppProps } from './App';
7
-
8
- export class {{name}} implements ComponentFramework.StandardControl<IInputs, IOutputs> {
9
- container: HTMLDivElement;
10
- root: Root;
11
- context: ComponentFramework.Context<IInputs>;
12
- isTestHarness: boolean;
13
- props: AppProps;
14
-
15
- /**
16
- * Empty constructor.
17
- */
18
- constructor() {
19
-
20
- }
21
-
22
- /**
23
- * Used to initialize the control instance. Controls can kick off remote server calls and other initialization actions here.
24
- * Data-set values are not initialized here, use updateView.
25
- * @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.
26
- * @param notifyOutputChanged A callback method to alert the framework that the control has new outputs ready to be retrieved asynchronously.
27
- * @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.
28
- * @param container If a control is marked control-type='standard', it will receive an empty div element within which it can render its content.
29
- */
30
- public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container: HTMLDivElement): void {
31
- initializeIcons(undefined, { disableWarnings: true });
32
-
33
- this.container = container;
34
- this.context = context;
35
- this.isTestHarness = document.getElementById('control-dimensions') !== null;
36
- }
37
-
38
-
39
- /**
40
- * 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.
41
- * @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
42
- */
43
- public updateView(context: ComponentFramework.Context<IInputs>): void {
44
- this.props = {
45
- isTestHarness: this.isTestHarness
46
- };
47
-
48
- ReactDOM.render(
49
- React.createElement(App, this.props),
50
- this.container
51
- );
52
- }
53
-
54
- /**
55
- * It is called by the framework prior to a control receiving new data.
56
- * @returns an object based on nomenclature defined in manifest, expecting object[s] for property marked as “bound” or “output”
57
- */
58
- public getOutputs(): IOutputs {
59
- return {};
60
- }
61
-
62
- /**
63
- * Called when the control is to be removed from the DOM tree. Controls should use this call for cleanup.
64
- * i.e. cancelling any pending remote calls, removing listeners, etc.
65
- */
66
- public destroy(): void {
67
- ReactDOM.unmountComponentAtNode(this.container);
68
- }
69
-
70
- }