Skip to content

Commit dfdf940

Browse files
committed
chore(devextreme-nx-infra-plugin): relocate build script to package
1 parent a292ebd commit dfdf940

File tree

5 files changed

+41
-30
lines changed

5 files changed

+41
-30
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"license": "MIT",
55
"author": "Developer Express Inc.",
66
"scripts": {
7-
"postinstall": "npx ts-node tools/scripts/build-nx-plugin.ts --force",
87
"devextreme:inject-descriptions-to-bundle": "dx-tools inject-descriptions --target-path ./packages/devextreme/ts/dx.all.d.ts --artifacts ./node_modules/devextreme-metadata/dist",
98
"devextreme:inject-descriptions-to-modules": "dx-tools inject-descriptions --collapse-tags --sources ./packages/devextreme/js --artifacts ./node_modules/devextreme-metadata/dist",
109
"devextreme:inject-descriptions": "npm run devextreme:inject-descriptions-to-bundle && npm run devextreme:inject-descriptions-to-modules",

packages/nx-infra-plugin/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
"ts-jest": "29.1.3"
2424
},
2525
"scripts": {
26+
"postinstall": "npx ts-node --project scripts/tsconfig.json scripts/build.ts --force",
2627
"format:check": "prettier --check .",
2728
"format": "prettier --write .",
28-
"build": "npx ts-node ../../tools/scripts/build-nx-plugin.ts --force",
29+
"build": "npx ts-node --project scripts/tsconfig.json scripts/build.ts --force",
2930
"test": "pnpm --workspace-root nx test devextreme-nx-infra-plugin",
3031
"lint": "pnpm run format:check"
3132
}

tools/scripts/build-nx-plugin.ts renamed to packages/nx-infra-plugin/scripts/build.ts

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { execSync } from 'child_process';
22
import * as fs from 'fs';
33
import * as path from 'path';
44

5-
const PLUGIN_DIR_NAME = 'nx-infra-plugin';
65
const DIST_DIR_NAME = 'dist';
76
const SRC_DIR_NAME = 'src';
87
const TEMP_TSCONFIG_NAME = 'tsconfig.bootstrap.json';
@@ -35,12 +34,12 @@ interface AssetCopyResult {
3534
}
3635

3736
const buildPathConfig = (rootDir: string): PathConfig => {
38-
const pluginDir = path.join(rootDir, '../../packages', PLUGIN_DIR_NAME);
37+
const pluginDir = path.join(rootDir, '..');
3938
return {
4039
pluginDir,
4140
distDir: path.join(pluginDir, DIST_DIR_NAME),
4241
srcDir: path.join(pluginDir, SRC_DIR_NAME),
43-
tsconfig: path.join(pluginDir, TSCONFIG_LIB_NAME)
42+
tsconfig: path.join(pluginDir, TSCONFIG_LIB_NAME),
4443
};
4544
};
4645

@@ -60,8 +59,8 @@ const createBootstrapConfig = (original: TsConfig): TsConfig => ({
6059
compilerOptions: {
6160
...original.compilerOptions,
6261
rootDir: undefined,
63-
outDir: `./${DIST_DIR_NAME}`
64-
}
62+
outDir: `./${DIST_DIR_NAME}`,
63+
},
6564
});
6665

6766
const writeTsConfig = (configPath: string, config: TsConfig): void => {
@@ -70,19 +69,16 @@ const writeTsConfig = (configPath: string, config: TsConfig): void => {
7069

7170
const compileTypeScript = (pluginDir: string, configPath: string): CompilationResult => {
7271
try {
73-
execSync(
74-
`npx tsc -p ${configPath}`,
75-
{
76-
cwd: pluginDir,
77-
stdio: 'inherit',
78-
env: { ...process.env, NODE_ENV: 'production' }
79-
}
80-
);
72+
execSync(`npx tsc -p ${configPath}`, {
73+
cwd: pluginDir,
74+
stdio: 'inherit',
75+
env: { ...process.env, NODE_ENV: 'production' },
76+
});
8177
return { success: true };
8278
} catch (error) {
8379
return {
8480
success: false,
85-
error: (error as Error).message
81+
error: (error as Error).message,
8682
};
8783
}
8884
};
@@ -120,14 +116,17 @@ const copyJsonAssets = (srcDir: string, destDir: string): AssetCopyResult => {
120116
const updateExecutorPaths = (config: Record<string, unknown>): Record<string, unknown> => {
121117
const executors = config.executors as Record<string, { implementation: string; schema: string }>;
122118

123-
const updated = Object.entries(executors).reduce((acc, [key, value]) => {
124-
acc[key] = {
125-
...value,
126-
implementation: value.implementation.replace('./src/', './'),
127-
schema: value.schema.replace('./src/', './')
128-
};
129-
return acc;
130-
}, {} as Record<string, { implementation: string; schema: string }>);
119+
const updated = Object.entries(executors).reduce(
120+
(acc, [key, value]) => {
121+
acc[key] = {
122+
...value,
123+
implementation: value.implementation.replace('./src/', './'),
124+
schema: value.schema.replace('./src/', './'),
125+
};
126+
return acc;
127+
},
128+
{} as Record<string, { implementation: string; schema: string }>,
129+
);
131130

132131
return { ...config, executors: updated };
133132
};
@@ -190,7 +189,7 @@ const buildPlugin = (paths: PathConfig, forceRebuild = false): void => {
190189
const parseArgs = (): { forceRebuild: boolean } => {
191190
const args = process.argv.slice(2);
192191
return {
193-
forceRebuild: args.includes('--force') || args.includes('-f')
192+
forceRebuild: args.includes('--force') || args.includes('-f'),
194193
};
195194
};
196195

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"module": "commonjs",
5+
"lib": ["ES2020"],
6+
"moduleResolution": "node",
7+
"esModuleInterop": true,
8+
"skipLibCheck": true,
9+
"strict": true,
10+
"resolveJsonModule": true,
11+
"types": ["node"]
12+
},
13+
"include": ["*.ts"]
14+
}

pnpm-lock.yaml

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)