create-powerapps-project 0.28.2 → 1.1.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/index.js CHANGED
@@ -1,27 +1,15 @@
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
- const minimist_1 = __importDefault(require("minimist"));
10
- // eslint-disable-next-line @typescript-eslint/no-var-requires
11
- const packageJson = require('../package.json');
12
- const argv = (0, minimist_1.default)(process.argv.slice(2));
13
- if (argv.version || argv.v) {
14
- console.log(`${packageJson.version}`);
15
- }
16
- else {
17
- plop_1.Plop.launch({
18
- cwd: process.cwd(),
19
- configPath: node_path_1.default.join(__dirname, 'plopfile.js')
20
- }, env => {
21
- const options = {
22
- ...env,
23
- dest: process.cwd()
24
- };
25
- return (0, plop_1.run)(options, undefined, true);
26
- });
27
- }
2
+ import { Plop, run } from 'plop';
3
+ import path, { dirname } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+ Plop.prepare({
7
+ cwd: process.cwd(),
8
+ configPath: path.join(__dirname, 'plopfile.js')
9
+ }, (env) => {
10
+ const options = {
11
+ ...env,
12
+ dest: process.cwd()
13
+ };
14
+ return run(options, undefined, true);
15
+ });
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.nugetRestore = 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 'node:https';
2
+ import { spawnSync } from 'node: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;
@@ -30,12 +24,10 @@ const getNugetPackageVersions = (name) => {
30
24
  });
31
25
  });
32
26
  };
33
- exports.getNugetPackageVersions = getNugetPackageVersions;
34
- const nugetRestore = async () => {
27
+ export const nugetRestore = async () => {
35
28
  // Install nuget packages
36
29
  if (process.env.JEST_WORKER_ID !== undefined) {
37
30
  return;
38
31
  }
39
- (0, child_process_1.spawnSync)('dotnet', ['restore'], { cwd: process.cwd(), stdio: 'inherit' });
32
+ spawnSync('dotnet', ['restore'], { cwd: process.cwd(), stdio: 'inherit' });
40
33
  };
41
- exports.nugetRestore = nugetRestore;
@@ -1,22 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.install = void 0;
4
- /* eslint-disable @typescript-eslint/no-explicit-any */
5
- const child_process_1 = require("child_process");
6
- const install = async (packageManager, packages) => {
1
+ import { spawnSync } from 'node:child_process';
2
+ export const install = async (packageManager, packages) => {
7
3
  if (process.env.JEST_WORKER_ID != undefined) {
8
4
  return;
9
5
  }
10
6
  if (packages) {
11
7
  if (packages.devDependencies) {
12
- (0, child_process_1.spawnSync)(packageManager, ['add', ...packages.devDependencies], { stdio: 'inherit', shell: true });
8
+ spawnSync(packageManager, ['add', ...packages.devDependencies], { stdio: 'inherit', shell: true });
13
9
  }
14
10
  if (packages.dependencies) {
15
- (0, child_process_1.spawnSync)(packageManager, ['add', ...packages.dependencies], { stdio: 'inherit', shell: true });
11
+ spawnSync(packageManager, ['add', ...packages.dependencies], { stdio: 'inherit', shell: true });
16
12
  }
17
13
  }
18
14
  else {
19
- (0, child_process_1.spawnSync)(packageManager, ['install'], { stdio: 'inherit', shell: true });
15
+ spawnSync(packageManager, ['install'], { stdio: 'inherit', shell: true });
20
16
  }
21
17
  };
22
- exports.install = install;
@@ -1,51 +1,24 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const path_1 = __importDefault(require("path"));
30
- const child_process_1 = require("child_process");
31
- const fs_1 = __importDefault(require("fs"));
32
- const nuget = __importStar(require("./nuget"));
33
- const pkg = __importStar(require("./packageManager"));
1
+ import path, { dirname } from 'node:path';
2
+ import { spawnSync, spawn } from 'node:child_process';
3
+ import { fileURLToPath } from 'node:url';
4
+ import fs from 'node:fs';
5
+ import * as nuget from './nuget.js';
6
+ import * as pkg from './packageManager.js';
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
34
8
  const didSucceed = (code) => `${code}` === '0';
35
- exports.default = (plop) => {
9
+ export default (plop) => {
36
10
  plop.setDefaultInclude({ actionTypes: true });
37
11
  plop.setActionType('addSolution', async (answers) => {
38
12
  // Add solution
39
- (0, child_process_1.spawnSync)('dotnet', ['new', 'sln', '-n', answers.name], { cwd: process.cwd(), stdio: 'inherit' });
40
- (0, child_process_1.spawnSync)('dotnet', ['sln', 'add', `${answers.name}.csproj`], { cwd: process.cwd(), stdio: 'inherit' });
13
+ spawnSync('dotnet', ['new', 'sln', '-n', answers.name], { cwd: process.cwd(), stdio: 'inherit' });
14
+ spawnSync('dotnet', ['sln', 'add', `${answers.name}.csproj`], { cwd: process.cwd(), stdio: 'inherit' });
41
15
  return 'added dotnet solution';
42
16
  });
43
17
  plop.setActionType('addScript', async (answers) => {
44
- const packagePath = path_1.default.resolve(process.cwd(), 'package.json');
45
- // eslint-disable-next-line @typescript-eslint/no-var-requires
46
- const packageJson = require(packagePath);
18
+ const packagePath = path.resolve(process.cwd(), 'package.json');
19
+ const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8'));
47
20
  packageJson.scripts[answers.scriptKey] = answers.scriptValue;
48
- await fs_1.default.promises.writeFile(packagePath, JSON.stringify(packageJson, null, 4), 'utf8');
21
+ await fs.promises.writeFile(packagePath, JSON.stringify(packageJson, null, 4), 'utf8');
49
22
  return `added ${answers.scriptKey} script to package.json`;
50
23
  });
51
24
  plop.setActionType('npmInstall', async (answers) => {
@@ -57,13 +30,13 @@ exports.default = (plop) => {
57
30
  return 'restored nuget packages';
58
31
  });
59
32
  plop.setActionType('signAssembly', async (answers) => {
60
- const keyPath = path_1.default.resolve(process.cwd(), `${answers.name}.snk`);
33
+ const keyPath = path.resolve(process.cwd(), `${answers.name}.snk`);
61
34
  return new Promise((resolve, reject) => {
62
35
  if (process.env.JEST_WORKER_ID !== undefined) {
63
36
  resolve('Testing so no need to sign');
64
37
  }
65
38
  else {
66
- const sign = (0, child_process_1.spawn)(path_1.default.resolve(__dirname, '..', 'bin', 'sn.exe'), ['-q', '-k', keyPath], { stdio: 'inherit' });
39
+ const sign = spawn(path.resolve(__dirname, '..', 'bin', 'sn.exe'), ['-q', '-k', keyPath], { stdio: 'inherit' });
67
40
  sign.on('close', (code) => {
68
41
  if (didSucceed(code)) {
69
42
  resolve('signed assembly');
@@ -85,7 +58,7 @@ exports.default = (plop) => {
85
58
  args.push('-fw', 'react');
86
59
  }
87
60
  return new Promise((resolve, reject) => {
88
- const pac = (0, child_process_1.spawn)('pac', args, { stdio: 'inherit' });
61
+ const pac = spawn('pac', args, { stdio: 'inherit' });
89
62
  pac.on('close', (code) => {
90
63
  if (didSucceed(code)) {
91
64
  resolve('pcf project created');
package/lib/plopfile.js CHANGED
@@ -1,17 +1,10 @@
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
- const path_1 = __importDefault(require("path"));
7
- const fs_1 = __importDefault(require("fs"));
8
- const nuget_1 = require("./nuget");
9
- // eslint-disable-next-line @typescript-eslint/no-var-requires
10
- const version = require('../package').version;
1
+ import path from 'node:path';
2
+ import fs from 'node:fs';
3
+ import { getNugetPackageVersions } from './nuget.js';
11
4
  /* eslint-disable @typescript-eslint/no-explicit-any */
12
- exports.default = (plop) => {
13
- plop.setWelcomeMessage(`Creating new Dataverse project using create-powerapps-project v${version}. Please choose type of project to create.`);
14
- plop.load('./plopActions');
5
+ export default async (plop) => {
6
+ plop.setWelcomeMessage('Creating new Dataverse project using create-powerapps-project. Please choose type of project to create.');
7
+ await plop.load('./plopActions');
15
8
  const packageQuestion = {
16
9
  type: 'list',
17
10
  name: 'package',
@@ -94,7 +87,7 @@ exports.default = (plop) => {
94
87
  },
95
88
  choices: async (answers) => {
96
89
  const crmPackage = answers.pluginPackage ? 'Microsoft.CrmSdk.CoreAssemblies' : 'Microsoft.CrmSdk.Workflow';
97
- const versions = await (0, nuget_1.getNugetPackageVersions)(crmPackage);
90
+ const versions = await getNugetPackageVersions(crmPackage);
98
91
  return versions;
99
92
  }
100
93
  },
@@ -140,14 +133,14 @@ exports.default = (plop) => {
140
133
  data.org = new URL(data.server).hostname.split('.')[0];
141
134
  return [
142
135
  async (answers) => {
143
- const xrmVersions = await (0, nuget_1.getNugetPackageVersions)('JourneyTeam.Xrm');
136
+ const xrmVersions = await getNugetPackageVersions('JourneyTeam.Xrm');
144
137
  answers.xrmVersion = xrmVersions.shift();
145
138
  return `retrieved latest JourneyTeam.Xrm version ${answers.xrmVersion}`;
146
139
  },
147
140
  {
148
141
  type: 'add',
149
142
  templateFile: '../plop-templates/assembly/assembly.csproj.hbs',
150
- path: path_1.default.resolve(process.cwd(), '{{name}}.csproj'),
143
+ path: path.resolve(process.cwd(), '{{name}}.csproj'),
151
144
  skip: (answers) => {
152
145
  if (answers.pluginPackage) {
153
146
  return 'generating plugin package';
@@ -160,7 +153,7 @@ exports.default = (plop) => {
160
153
  {
161
154
  type: 'add',
162
155
  templateFile: '../plop-templates/assembly/package.csproj.hbs',
163
- path: path_1.default.resolve(process.cwd(), '{{name}}.csproj'),
156
+ path: path.resolve(process.cwd(), '{{name}}.csproj'),
164
157
  skip: (answers) => {
165
158
  if (!answers.pluginPackage) {
166
159
  return 'generating regular assembly';
@@ -173,7 +166,7 @@ exports.default = (plop) => {
173
166
  {
174
167
  type: 'add',
175
168
  templateFile: '../plop-templates/assembly/dataverse.config.json.hbs',
176
- path: path_1.default.resolve(process.cwd(), 'dataverse.config.json'),
169
+ path: path.resolve(process.cwd(), 'dataverse.config.json'),
177
170
  skip: (answers) => {
178
171
  if (answers.pluginPackage) {
179
172
  return 'generating plugin package';
@@ -186,7 +179,7 @@ exports.default = (plop) => {
186
179
  {
187
180
  type: 'add',
188
181
  templateFile: '../plop-templates/assembly/dataverse.package.config.json.hbs',
189
- path: path_1.default.resolve(process.cwd(), 'dataverse.config.json'),
182
+ path: path.resolve(process.cwd(), 'dataverse.config.json'),
190
183
  skip: (answers) => {
191
184
  if (!answers.pluginPackage) {
192
185
  return 'generating regular assembly';
@@ -277,19 +270,19 @@ exports.default = (plop) => {
277
270
  {
278
271
  type: 'add',
279
272
  templateFile: '../plop-templates/pcf/tsconfig.json',
280
- path: path_1.default.resolve(process.cwd(), 'tsconfig.json'),
273
+ path: path.resolve(process.cwd(), 'tsconfig.json'),
281
274
  force: true
282
275
  },
283
276
  {
284
277
  type: 'add',
285
278
  templateFile: '../plop-templates/pcf/plopfile.js',
286
- path: path_1.default.resolve(process.cwd(), 'plopfile.js'),
279
+ path: path.resolve(process.cwd(), 'plopfile.js'),
287
280
  force: true
288
281
  },
289
282
  {
290
283
  type: 'add',
291
284
  templateFile: '../plop-templates/pcf/.gitattributes',
292
- path: path_1.default.resolve(process.cwd(), '.gitattributes'),
285
+ path: path.resolve(process.cwd(), '.gitattributes'),
293
286
  force: true
294
287
  },
295
288
  {
@@ -349,7 +342,7 @@ exports.default = (plop) => {
349
342
  },
350
343
  async (answers) => {
351
344
  if (answers.react) {
352
- await fs_1.default.promises.rm(path_1.default.resolve(process.cwd(), answers.name, 'HelloWorld.tsx'));
345
+ await fs.promises.rm(path.resolve(process.cwd(), answers.name, 'HelloWorld.tsx'));
353
346
  return 'removed HelloWorld component';
354
347
  }
355
348
  return 'react not included';
@@ -375,7 +368,7 @@ exports.default = (plop) => {
375
368
  type: 'input',
376
369
  name: 'name',
377
370
  message: 'project name',
378
- default: path_1.default.basename(process.cwd())
371
+ default: path.basename(process.cwd())
379
372
  },
380
373
  {
381
374
  type: 'input',
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "create-powerapps-project",
3
3
  "description": "💧 plop generator for Dataverse development",
4
- "version": "0.28.2",
4
+ "version": "1.1.0",
5
5
  "license": "MIT",
6
- "main": "lib/index.js",
6
+ "exports": "./lib/index.js",
7
+ "engines": {
8
+ "node": ">=14.16"
9
+ },
7
10
  "bin": {
8
11
  "create-powerapps-project": "lib/index.js"
9
12
  },
@@ -21,12 +24,11 @@
21
24
  "lint": "eslint",
22
25
  "clean": "rimraf lib"
23
26
  },
27
+ "type": "module",
24
28
  "dependencies": {
25
- "plop": "^2.7.6",
26
- "minimist": "^1.2.6"
29
+ "plop": "^3.1.2"
27
30
  },
28
31
  "devDependencies": {
29
- "@types/minimist": "^1.2.2",
30
32
  "@types/node": "^14.14.21"
31
33
  },
32
34
  "volta": {
@@ -1,3 +1,3 @@
1
- module.exports = function (plop) {
2
- plop.load('powerapps-project-assembly');
1
+ module.exports = async function (plop) {
2
+ await plop.load('powerapps-project-assembly');
3
3
  };