Skip to content

Commit b6c4c95

Browse files
committedDec 18, 2023
chore(web): build script for the enterprise packages and skip cache
1 parent 2a97b9c commit b6c4c95

File tree

9 files changed

+266
-9
lines changed

9 files changed

+266
-9
lines changed
 

‎enterprise/packages/auth/check-ee.mjs

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import spawn from 'cross-spawn';
2+
import { fileURLToPath } from 'url';
3+
import path from 'path';
4+
import * as fs from 'fs';
5+
const dirname = path.dirname(fileURLToPath(import.meta.url));
6+
7+
const ROOT_PATH = path.resolve(dirname);
8+
const ENCODING_TYPE = 'utf8';
9+
const NEW_LINE_CHAR = '\n';
10+
11+
class CliLogs {
12+
constructor() {
13+
this._logs = [];
14+
this.log = this.log.bind(this);
15+
}
16+
17+
log(log) {
18+
const cleanLog = log.trim();
19+
if (cleanLog.length) {
20+
this._logs.push(cleanLog);
21+
}
22+
}
23+
24+
get logs() {
25+
return this._logs;
26+
}
27+
28+
get joinedLogs() {
29+
return this.logs.join(NEW_LINE_CHAR);
30+
}
31+
}
32+
33+
function pnpmRun(...args) {
34+
const logData = new CliLogs();
35+
let pnpmProcess;
36+
37+
return new Promise((resolve, reject) => {
38+
const processOptions = {
39+
cwd: ROOT_PATH,
40+
env: process.env,
41+
};
42+
43+
pnpmProcess = spawn('pnpm', args, processOptions);
44+
45+
pnpmProcess.stdin.setEncoding(ENCODING_TYPE);
46+
pnpmProcess.stdout.setEncoding(ENCODING_TYPE);
47+
pnpmProcess.stderr.setEncoding(ENCODING_TYPE);
48+
pnpmProcess.stdout.on('data', logData.log);
49+
pnpmProcess.stderr.on('data', logData.log);
50+
51+
pnpmProcess.on('close', (code) => {
52+
if (code !== 0) {
53+
reject(logData.joinedLogs);
54+
} else {
55+
resolve(logData.joinedLogs);
56+
}
57+
});
58+
});
59+
}
60+
61+
const hasSrcFolder = fs.existsSync(path.resolve(ROOT_PATH, 'src'));
62+
if (hasSrcFolder) {
63+
await pnpmRun('build:esm');
64+
}

‎enterprise/packages/auth/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"private": false,
55
"main": "dist/index.js",
66
"scripts": {
7-
"build": "echo 'skip build in the ci'",
8-
"build-ee": "node_modules/.bin/tsc -p tsconfig.json",
7+
"build": "node ./check-ee.mjs",
8+
"build:esm": "node_modules/.bin/tsc -p tsconfig.json",
99
"build:watch": "node_modules/.bin/tsc -w -p tsconfig.json",
1010
"lint": "eslint src --no-error-on-unmatched-pattern",
1111
"test": "echo 'skip test in the ci'",
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import spawn from 'cross-spawn';
2+
import { fileURLToPath } from 'url';
3+
import path from 'path';
4+
import * as fs from 'fs';
5+
const dirname = path.dirname(fileURLToPath(import.meta.url));
6+
7+
const ROOT_PATH = path.resolve(dirname);
8+
const ENCODING_TYPE = 'utf8';
9+
const NEW_LINE_CHAR = '\n';
10+
11+
class CliLogs {
12+
constructor() {
13+
this._logs = [];
14+
this.log = this.log.bind(this);
15+
}
16+
17+
log(log) {
18+
const cleanLog = log.trim();
19+
if (cleanLog.length) {
20+
this._logs.push(cleanLog);
21+
}
22+
}
23+
24+
get logs() {
25+
return this._logs;
26+
}
27+
28+
get joinedLogs() {
29+
return this.logs.join(NEW_LINE_CHAR);
30+
}
31+
}
32+
33+
function pnpmRun(...args) {
34+
const logData = new CliLogs();
35+
let pnpmProcess;
36+
37+
return new Promise((resolve, reject) => {
38+
const processOptions = {
39+
cwd: ROOT_PATH,
40+
env: process.env,
41+
};
42+
43+
pnpmProcess = spawn('pnpm', args, processOptions);
44+
45+
pnpmProcess.stdin.setEncoding(ENCODING_TYPE);
46+
pnpmProcess.stdout.setEncoding(ENCODING_TYPE);
47+
pnpmProcess.stderr.setEncoding(ENCODING_TYPE);
48+
pnpmProcess.stdout.on('data', logData.log);
49+
pnpmProcess.stderr.on('data', logData.log);
50+
51+
pnpmProcess.on('close', (code) => {
52+
if (code !== 0) {
53+
reject(logData.joinedLogs);
54+
} else {
55+
resolve(logData.joinedLogs);
56+
}
57+
});
58+
});
59+
}
60+
61+
const hasSrcFolder = fs.existsSync(path.resolve(ROOT_PATH, 'src'));
62+
if (hasSrcFolder) {
63+
await pnpmRun('build:esm');
64+
}

‎enterprise/packages/libs/dal/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"scripts": {
77
"afterinstall": "pnpm build",
88
"prebuild": "rimraf dist",
9-
"build": "echo 'skip build in the ci'",
10-
"build-ee": "cross-env node_modules/.bin/tsc -p tsconfig.build.json",
9+
"build": "node ./check-ee.mjs",
10+
"build:esm": "cross-env node_modules/.bin/tsc -p tsconfig.build.json",
1111
"build:watch": "cross-env node_modules/.bin/tsc -p tsconfig.build.json -w --preserveWatchOutput",
1212
"precommit": "lint-staged",
1313
"lint": "eslint src --no-error-on-unmatched-pattern",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import spawn from 'cross-spawn';
2+
import { fileURLToPath } from 'url';
3+
import path from 'path';
4+
import * as fs from 'fs';
5+
const dirname = path.dirname(fileURLToPath(import.meta.url));
6+
7+
const ROOT_PATH = path.resolve(dirname);
8+
const ENCODING_TYPE = 'utf8';
9+
const NEW_LINE_CHAR = '\n';
10+
11+
class CliLogs {
12+
constructor() {
13+
this._logs = [];
14+
this.log = this.log.bind(this);
15+
}
16+
17+
log(log) {
18+
const cleanLog = log.trim();
19+
if (cleanLog.length) {
20+
this._logs.push(cleanLog);
21+
}
22+
}
23+
24+
get logs() {
25+
return this._logs;
26+
}
27+
28+
get joinedLogs() {
29+
return this.logs.join(NEW_LINE_CHAR);
30+
}
31+
}
32+
33+
function pnpmRun(...args) {
34+
const logData = new CliLogs();
35+
let pnpmProcess;
36+
37+
return new Promise((resolve, reject) => {
38+
const processOptions = {
39+
cwd: ROOT_PATH,
40+
env: process.env,
41+
};
42+
43+
pnpmProcess = spawn('pnpm', args, processOptions);
44+
45+
pnpmProcess.stdin.setEncoding(ENCODING_TYPE);
46+
pnpmProcess.stdout.setEncoding(ENCODING_TYPE);
47+
pnpmProcess.stderr.setEncoding(ENCODING_TYPE);
48+
pnpmProcess.stdout.on('data', logData.log);
49+
pnpmProcess.stderr.on('data', logData.log);
50+
51+
pnpmProcess.on('close', (code) => {
52+
if (code !== 0) {
53+
reject(logData.joinedLogs);
54+
} else {
55+
resolve(logData.joinedLogs);
56+
}
57+
});
58+
});
59+
}
60+
61+
const hasSrcFolder = fs.existsSync(path.resolve(ROOT_PATH, 'src'));
62+
if (hasSrcFolder) {
63+
await pnpmRun('build:esm');
64+
await pnpmRun('build:types');
65+
}

‎enterprise/packages/translation-web/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
],
1414
"scripts": {
1515
"prebuild": "rimraf dist",
16-
"build": "echo 'skip build in the ci'",
17-
"build-ee": "npm run build:esm && npm run build:types",
16+
"build": "node ./check-ee.mjs",
1817
"build:esm": "cross-env node_modules/.bin/tsc -p tsconfig.esm.json",
1918
"build:esm:watch": "cross-env node_modules/.bin/tsc -p tsconfig.esm.json -w --preserveWatchOutput",
2019
"build:types": "tsc --declaration --emitDeclarationOnly --declarationMap --declarationDir dist/types -p tsconfig.json",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import spawn from 'cross-spawn';
2+
import { fileURLToPath } from 'url';
3+
import path from 'path';
4+
import * as fs from 'fs';
5+
const dirname = path.dirname(fileURLToPath(import.meta.url));
6+
7+
const ROOT_PATH = path.resolve(dirname);
8+
const ENCODING_TYPE = 'utf8';
9+
const NEW_LINE_CHAR = '\n';
10+
11+
class CliLogs {
12+
constructor() {
13+
this._logs = [];
14+
this.log = this.log.bind(this);
15+
}
16+
17+
log(log) {
18+
const cleanLog = log.trim();
19+
if (cleanLog.length) {
20+
this._logs.push(cleanLog);
21+
}
22+
}
23+
24+
get logs() {
25+
return this._logs;
26+
}
27+
28+
get joinedLogs() {
29+
return this.logs.join(NEW_LINE_CHAR);
30+
}
31+
}
32+
33+
function pnpmRun(...args) {
34+
const logData = new CliLogs();
35+
let pnpmProcess;
36+
37+
return new Promise((resolve, reject) => {
38+
const processOptions = {
39+
cwd: ROOT_PATH,
40+
env: process.env,
41+
};
42+
43+
pnpmProcess = spawn('pnpm', args, processOptions);
44+
45+
pnpmProcess.stdin.setEncoding(ENCODING_TYPE);
46+
pnpmProcess.stdout.setEncoding(ENCODING_TYPE);
47+
pnpmProcess.stderr.setEncoding(ENCODING_TYPE);
48+
pnpmProcess.stdout.on('data', logData.log);
49+
pnpmProcess.stderr.on('data', logData.log);
50+
51+
pnpmProcess.on('close', (code) => {
52+
if (code !== 0) {
53+
reject(logData.joinedLogs);
54+
} else {
55+
resolve(logData.joinedLogs);
56+
}
57+
});
58+
});
59+
}
60+
61+
const hasSrcFolder = fs.existsSync(path.resolve(ROOT_PATH, 'src'));
62+
if (hasSrcFolder) {
63+
await pnpmRun('build:esm');
64+
}

‎enterprise/packages/translation/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"private": false,
55
"main": "dist/index.js",
66
"scripts": {
7-
"build": "echo 'skip build in the ci'",
8-
"build-ee": "node_modules/.bin/tsc -p tsconfig.json",
7+
"build": "node ./check-ee.mjs",
8+
"build:esm": "node_modules/.bin/tsc -p tsconfig.json",
99
"build:watch": "node_modules/.bin/tsc -w -p tsconfig.json",
1010
"test": "echo 'skip test in the ci'",
1111
"lint": "eslint src --no-error-on-unmatched-pattern",

‎nx.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"default": {
66
"runner": "@nrwl/nx-cloud",
77
"options": {
8-
"cacheableOperations": ["build", "test", "lint", "package", "prepare", "build-ee"],
8+
"cacheableOperations": ["build", "test", "lint", "package", "prepare"],
99
"canTrackAnalytics": false,
1010
"accessToken": "N2EyNDhhMGUtYmJkNS00YzQ5LTg5NDYtODg5ZmE2NDE5YWNmfHJlYWQtd3JpdGU="
1111
}
@@ -15,6 +15,7 @@
1515
"build": [
1616
{
1717
"target": "build",
18+
"inputs": ["!{projectRoot}/enterprise/**/*"],
1819
"projects": "dependencies"
1920
}
2021
],

0 commit comments

Comments
 (0)
Please sign in to comment.