mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(core): Fix Public API failing to build on Windows (#3499)
* ✨ Add build script * 📦 Add dependencies * 📦 Update package-lock.json * 👕 Ignore `build.mjs`
This commit is contained in:
parent
955db0ab10
commit
c121952324
|
@ -1,2 +1,3 @@
|
|||
packages/editor-ui
|
||||
packages/design-system
|
||||
packages/cli/scripts/build.mjs
|
||||
|
|
65
package-lock.json
generated
65
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "n8n",
|
||||
"version": "0.180.0",
|
||||
"version": "0.181.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "n8n",
|
||||
"version": "0.180.0",
|
||||
"version": "0.181.2",
|
||||
"dependencies": {
|
||||
"@apidevtools/swagger-cli": "4.0.0",
|
||||
"@babel/core": "^7.14.6",
|
||||
|
@ -77,6 +77,7 @@
|
|||
"@types/redis": "^2.8.11",
|
||||
"@types/request-promise-native": "~1.0.15",
|
||||
"@types/sanitize-html": "^2.6.2",
|
||||
"@types/shelljs": "^0.8.11",
|
||||
"@types/showdown": "^1.9.4",
|
||||
"@types/snowflake-sdk": "^1.5.1",
|
||||
"@types/ssh2-sftp-client": "^5.1.0",
|
||||
|
@ -232,6 +233,7 @@
|
|||
"sanitize-html": "2.7.0",
|
||||
"sass": "^1.26.5",
|
||||
"sass-loader": "^8.0.2",
|
||||
"shelljs": "^0.8.5",
|
||||
"showdown": "^2.0.3",
|
||||
"simple-git": "^3.5.0",
|
||||
"snowflake-sdk": "^1.5.3",
|
||||
|
@ -14576,6 +14578,15 @@
|
|||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/shelljs": {
|
||||
"version": "0.8.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.8.11.tgz",
|
||||
"integrity": "sha512-x9yaMvEh5BEaZKeVQC4vp3l+QoFj3BXcd4aYfuKSzIIyihjdVARAadYy3SMNIz0WCCdS2vB9JL/U6GQk5PaxQw==",
|
||||
"dependencies": {
|
||||
"@types/glob": "*",
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/showdown": {
|
||||
"version": "1.9.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/showdown/-/showdown-1.9.4.tgz",
|
||||
|
@ -51378,6 +51389,30 @@
|
|||
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz",
|
||||
"integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw=="
|
||||
},
|
||||
"node_modules/shelljs": {
|
||||
"version": "0.8.5",
|
||||
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.5.tgz",
|
||||
"integrity": "sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==",
|
||||
"dependencies": {
|
||||
"glob": "^7.0.0",
|
||||
"interpret": "^1.0.0",
|
||||
"rechoir": "^0.6.2"
|
||||
},
|
||||
"bin": {
|
||||
"shjs": "bin/shjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/shelljs/node_modules/interpret": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz",
|
||||
"integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==",
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/shellwords": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
||||
|
@ -71951,6 +71986,15 @@
|
|||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/shelljs": {
|
||||
"version": "0.8.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.8.11.tgz",
|
||||
"integrity": "sha512-x9yaMvEh5BEaZKeVQC4vp3l+QoFj3BXcd4aYfuKSzIIyihjdVARAadYy3SMNIz0WCCdS2vB9JL/U6GQk5PaxQw==",
|
||||
"requires": {
|
||||
"@types/glob": "*",
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/showdown": {
|
||||
"version": "1.9.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/showdown/-/showdown-1.9.4.tgz",
|
||||
|
@ -100906,6 +100950,23 @@
|
|||
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz",
|
||||
"integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw=="
|
||||
},
|
||||
"shelljs": {
|
||||
"version": "0.8.5",
|
||||
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.5.tgz",
|
||||
"integrity": "sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==",
|
||||
"requires": {
|
||||
"glob": "^7.0.0",
|
||||
"interpret": "^1.0.0",
|
||||
"rechoir": "^0.6.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"interpret": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz",
|
||||
"integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"shellwords": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
"bin": "n8n"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "run-script-os",
|
||||
"build:default": "tsc && cp -r ./src/UserManagement/email/templates ./dist/src/UserManagement/email && cp ./src/PublicApi/swaggerTheme.css ./dist/src/PublicApi/swaggerTheme.css; find ./src/PublicApi -iname 'openapi.yml' -exec swagger-cli bundle {} --type yaml --outfile \"./dist\"/{} \\;",
|
||||
"build:windows": "tsc && xcopy /E /I src\\UserManagement\\email\\templates dist\\src\\UserManagement\\email\\templates",
|
||||
"build": "node scripts/build.mjs",
|
||||
"dev": "concurrently -k -n \"TypeScript,Node\" -c \"yellow.bold,cyan.bold\" \"npm run watch\" \"nodemon\"",
|
||||
"format": "cd ../.. && node_modules/prettier/bin-prettier.js packages/cli/**/**.ts --write",
|
||||
"lint": "cd ../.. && node_modules/eslint/bin/eslint.js packages/cli",
|
||||
|
@ -100,6 +98,7 @@
|
|||
"@rudderstack/rudder-sdk-node": "1.0.6",
|
||||
"@types/json-diff": "^0.5.1",
|
||||
"@types/jsonwebtoken": "^8.5.2",
|
||||
"@types/shelljs": "^0.8.11",
|
||||
"@types/swagger-ui-express": "^4.1.3",
|
||||
"@types/yamljs": "^0.2.31",
|
||||
"basic-auth": "^2.0.1",
|
||||
|
@ -146,6 +145,7 @@
|
|||
"pg": "^8.3.0",
|
||||
"prom-client": "^13.1.0",
|
||||
"request-promise-native": "^1.0.7",
|
||||
"shelljs": "^0.8.5",
|
||||
"sqlite3": "^5.0.2",
|
||||
"sse-channel": "^3.1.1",
|
||||
"swagger-ui-express": "^4.3.0",
|
||||
|
|
59
packages/cli/scripts/build.mjs
Normal file
59
packages/cli/scripts/build.mjs
Normal file
|
@ -0,0 +1,59 @@
|
|||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import shell from 'shelljs';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const ROOT_DIR = path.resolve(__dirname, '..');
|
||||
const SPEC_FILENAME = 'openapi.yml';
|
||||
const SPEC_THEME_FILENAME = 'swaggerTheme.css';
|
||||
|
||||
const userManagementEnabled = process.env.N8N_USER_MANAGEMENT_DISABLED !== 'true';
|
||||
const publicApiEnabled = process.env.N8N_PUBLIC_API_DISABLED !== 'true';
|
||||
|
||||
shell.rm('-rf', path.resolve(ROOT_DIR, 'dist'));
|
||||
|
||||
shell.exec('tsc');
|
||||
|
||||
if (userManagementEnabled) {
|
||||
copyUserManagementEmailTemplates();
|
||||
}
|
||||
|
||||
if (publicApiEnabled) {
|
||||
copySwaggerTheme();
|
||||
bundleOpenApiSpecs();
|
||||
}
|
||||
|
||||
function copyUserManagementEmailTemplates(rootDir = ROOT_DIR) {
|
||||
const templates = {
|
||||
source: path.resolve(rootDir, 'src', 'UserManagement', 'email', 'templates'),
|
||||
destination: path.resolve(rootDir, 'dist', 'src', 'UserManagement', 'email'),
|
||||
};
|
||||
|
||||
shell.cp('-r', templates.source, templates.destination);
|
||||
}
|
||||
|
||||
function copySwaggerTheme(rootDir = ROOT_DIR, themeFilename = SPEC_THEME_FILENAME) {
|
||||
const swaggerTheme = {
|
||||
source: path.resolve(rootDir, 'src', 'PublicApi', themeFilename),
|
||||
destination: path.resolve(rootDir, 'dist', 'src', 'PublicApi'),
|
||||
};
|
||||
|
||||
shell.cp('-r', swaggerTheme.source, swaggerTheme.destination);
|
||||
}
|
||||
|
||||
function bundleOpenApiSpecs(rootDir = ROOT_DIR, specFileName = SPEC_FILENAME) {
|
||||
const publicApiDir = path.resolve(rootDir, 'src', 'PublicApi');
|
||||
|
||||
shell
|
||||
.find(publicApiDir)
|
||||
.reduce((acc, cur) => {
|
||||
return cur.endsWith(specFileName) ? [...acc, path.relative('.', cur)] : acc;
|
||||
}, [])
|
||||
.forEach((specPath) => {
|
||||
const distSpecPath = path.resolve(rootDir, 'dist', specPath);
|
||||
const command = `swagger-cli bundle ${specPath} --type yaml --outfile ${distSpecPath}`;
|
||||
shell.exec(command, { silent: true });
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue