dazscript-framework 1.0.31 → 1.0.32

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.
@@ -153,11 +153,65 @@ function run(command, args, options) {
153
153
  return result;
154
154
  }
155
155
 
156
+ function getNpmInvocation(args, platform) {
157
+ const npmArgs = args || [];
158
+ if ((platform || process.platform) !== 'win32') {
159
+ return { command: 'npm', args: npmArgs };
160
+ }
161
+
162
+ const npmCliPath = path.join(path.dirname(process.execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js');
163
+ if (fs.existsSync(npmCliPath)) {
164
+ return { command: process.execPath, args: [npmCliPath].concat(npmArgs) };
165
+ }
166
+
167
+ return { command: 'npm.cmd', args: npmArgs };
168
+ }
169
+
156
170
  function writeFile(filePath, content) {
157
171
  fs.mkdirSync(path.dirname(filePath), { recursive: true });
158
172
  fs.writeFileSync(filePath, content, 'utf8');
159
173
  }
160
174
 
175
+ const fixtureBuildDependencies = [
176
+ '@babel/core',
177
+ '@babel/plugin-proposal-class-properties',
178
+ '@babel/plugin-proposal-decorators',
179
+ '@babel/plugin-transform-arrow-functions',
180
+ '@babel/plugin-transform-block-scoping',
181
+ '@babel/plugin-transform-class-properties',
182
+ '@babel/plugin-transform-private-methods',
183
+ '@babel/plugin-transform-private-property-in-object',
184
+ '@babel/preset-env',
185
+ '@babel/preset-typescript',
186
+ 'babel-core',
187
+ 'babel-loader',
188
+ 'babel-plugin-transform-class-properties',
189
+ 'babel-plugin-transform-typescript-metadata',
190
+ 'glob',
191
+ 'ts-loader',
192
+ 'tsconfig-paths-webpack-plugin',
193
+ 'typescript',
194
+ 'webpack',
195
+ ];
196
+
197
+ function getFixtureBuildDependencies(frameworkRoot) {
198
+ const frameworkPackageJson = JSON.parse(
199
+ fs.readFileSync(path.join(frameworkRoot, 'package.json'), 'utf8')
200
+ );
201
+ const availableDependencies = {
202
+ ...(frameworkPackageJson.dependencies || {}),
203
+ ...(frameworkPackageJson.devDependencies || {}),
204
+ };
205
+
206
+ return fixtureBuildDependencies.reduce((result, dependencyName) => {
207
+ const version = availableDependencies[dependencyName];
208
+ if (version) {
209
+ result[dependencyName] = version;
210
+ }
211
+ return result;
212
+ }, {});
213
+ }
214
+
161
215
  function buildFixtureProject(options) {
162
216
  fs.rmSync(options.fixtureRoot, { recursive: true, force: true });
163
217
  fs.mkdirSync(path.join(options.fixtureRoot, 'src'), { recursive: true });
@@ -171,7 +225,7 @@ function buildFixtureProject(options) {
171
225
  'dazscript-framework': `file:${options.frameworkRoot}`,
172
226
  'dazscript-types': '^1.0.1',
173
227
  },
174
- devDependencies: {},
228
+ devDependencies: getFixtureBuildDependencies(options.frameworkRoot),
175
229
  }, null, 2));
176
230
 
177
231
  writeFile(path.join(options.fixtureRoot, 'dazscript.config.ts'), [
@@ -223,8 +277,10 @@ function buildFixtureProject(options) {
223
277
  }, null, 2));
224
278
 
225
279
  fs.copyFileSync(options.fixturePath, path.join(options.fixtureRoot, 'src', `${options.fixtureName}.dsa.ts`));
226
- run('npm', ['install', '--ignore-scripts'], { cwd: options.fixtureRoot });
227
- run('npm', ['run', 'build'], { cwd: options.fixtureRoot });
280
+ const npmInstall = getNpmInvocation(['install', '--ignore-scripts']);
281
+ run(npmInstall.command, npmInstall.args, { cwd: options.fixtureRoot });
282
+ const npmBuild = getNpmInvocation(['run', 'build']);
283
+ run(npmBuild.command, npmBuild.args, { cwd: options.fixtureRoot });
228
284
  }
229
285
 
230
286
  function runDazFixture(options) {
@@ -296,6 +352,8 @@ async function runIntegration(rawOptions, injectedEnv, cwd) {
296
352
  module.exports = {
297
353
  loadEnvFile,
298
354
  normalizeForDaz,
355
+ getNpmInvocation,
356
+ getFixtureBuildDependencies,
299
357
  readIntegrationResult,
300
358
  resolveIntegrationOptions,
301
359
  buildFixtureProject,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dazscript-framework",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "author": "Freddy Diaz",
5
5
  "license": "MPL-2.0",
6
6
  "description": "",
@@ -5,6 +5,8 @@ import { afterEach, describe, expect, it } from 'vitest'
5
5
 
6
6
  const {
7
7
  loadEnvFile,
8
+ getFixtureBuildDependencies,
9
+ getNpmInvocation,
8
10
  readIntegrationResult,
9
11
  resolveIntegrationOptions,
10
12
  } = require('../../dist/scripts/integration')
@@ -78,6 +80,34 @@ describe('integration option resolution', () => {
78
80
  })
79
81
  })
80
82
 
83
+ describe('integration command resolution', () => {
84
+ it('uses node plus npm-cli on Windows so child_process can spawn without a shell', () => {
85
+ const invocation = getNpmInvocation(['--version'], 'win32')
86
+
87
+ expect(invocation.command).toMatch(/node(\.exe)?$/i)
88
+ expect(invocation.args[0]).toMatch(/npm-cli\.js$/)
89
+ expect(invocation.args[1]).toBe('--version')
90
+ })
91
+
92
+ it('uses npm on non-Windows platforms', () => {
93
+ expect(getNpmInvocation(['--version'], 'linux')).toEqual({
94
+ command: 'npm',
95
+ args: ['--version']
96
+ })
97
+ })
98
+ })
99
+
100
+ describe('integration fixture build dependencies', () => {
101
+ it('includes webpack loader dependencies needed by generated fixture projects', () => {
102
+ const dependencies = getFixtureBuildDependencies(path.resolve(__dirname, '../..'))
103
+
104
+ expect(dependencies['babel-loader']).toBeTruthy()
105
+ expect(dependencies['ts-loader']).toBeTruthy()
106
+ expect(dependencies['webpack']).toBeTruthy()
107
+ expect(dependencies['typescript']).toBeTruthy()
108
+ })
109
+ })
110
+
81
111
  describe('integration result reader', () => {
82
112
  it('accepts successful result JSON', () => {
83
113
  const projectDir = makeProject()