diff --git a/.travis.yml b/.travis.yml index 3e53232bf3f..a668d7d0ea0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -74,8 +74,10 @@ jobs: script: &build-vercel-pkg # build the entire application - npm run build + - echo "Cleaning dev depandancies" + - npm prune --production - echo "Building vercel/pkg binary" - - npm run build-vercel-pkg + - node build-tools/replace_package_type.js module commonjs && npm run build-vercel-pkg deploy: &deploy-vercel-pkg provider: releases api_key: ${GITHUB_TOKEN} @@ -88,6 +90,8 @@ jobs: skip_cleanup: true on: tags: true + env: + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=true - stage: publish name: "Build & Publish linux binary" @@ -96,11 +100,18 @@ jobs: install: *slow-npm-ci script: *build-vercel-pkg deploy: *deploy-vercel-pkg + env: + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=true - stage: publish name: "Build & Publish windows binary" if: tag IS present os: windows + before_install: + - echo "Installing python 3" + - choco install python3 install: *slow-npm-ci script: *build-vercel-pkg deploy: *deploy-vercel-pkg + env: + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=true diff --git a/build-tools/post_install.js b/build-tools/post_install.js new file mode 100755 index 00000000000..81a4248590b --- /dev/null +++ b/build-tools/post_install.js @@ -0,0 +1,23 @@ +import {existsSync} from "fs"; +import {execSync} from "node:child_process"; + +/** + * Wrapper script to switch to either the source .ts or built .js script + * + * We check for presence of ts-node-dev and call npm run postinstall:dev + * Else we call npm run postinstall:prod. + * + * We are using npm run because it will take care of calling the binray on different platforms for us + */ + +if (existsSync("node_modules/.bin/ts-node-dev")) { + execSync( + "npm run postinstall:dev", + {stdio: "inherit"} + ); +} else { + execSync( + "npm run postinstall:prod", + {stdio: "inherit"} + ); +} diff --git a/build-tools/post_install.sh b/build-tools/post_install.sh deleted file mode 100755 index 2511078e0ea..00000000000 --- a/build-tools/post_install.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -if [ -f "./node_modules/.bin/ts-node-dev" ]; then - ./node_modules/.bin/ts-node-dev --quiet --project tsconfig.node.json src/cli/post-install.ts -else - node dist/cli/post-install.js -fi diff --git a/build-tools/replace_package_type.js b/build-tools/replace_package_type.js new file mode 100644 index 00000000000..62dca8e8ccb --- /dev/null +++ b/build-tools/replace_package_type.js @@ -0,0 +1,12 @@ +import {readFileSync, writeFileSync} from "fs"; + +/** + * Temporary script to replace module type on windows + */ + +let packageJson = readFileSync("package.json").toString(); +packageJson = packageJson.replace( + new RegExp(`"type":\\s*"${process.argv[2]}",`, "g"), + `"type": "${process.argv[3]}",` +) +writeFileSync("package.json", packageJson); diff --git a/package.json b/package.json index 9439bf37b07..e12589d24f2 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,9 @@ "build": "svelte-kit build && tsc --project tsconfig.node.json", "prepack": "./build-tools/replace_package_type.sh module commonjs", "postpack": "./build-tools/replace_package_type.sh commonjs module", - "postinstall": "./build-tools/post_install.sh", + "postinstall": "node build-tools/post_install.js", + "postinstall:dev": "ts-node-dev --quiet --project tsconfig.node.json src/cli/post-install.ts", + "postinstall:prod": "node dist/cli/post-install.js", "install-and-build": "npm install && npm run build", "package": "svelte-kit package", "preview": "svelte-kit preview", @@ -26,7 +28,7 @@ "cli": "ts-node-dev --quiet --project tsconfig.node.json -- src/cli/data-modeler-cli.ts", "bump-version": "ts-node-dev --quiet --project tsconfig.node.json -- src/cli/bump-version.ts", "manual-publish": "./build-tools/npm_publish.sh", - "build-vercel-pkg": "ts-node-dev --quiet --project tsconfig.node.json -- src/cli/build-vercel-pkg.ts" + "build-vercel-pkg": "node dist/cli/build-vercel-pkg.js" }, "devDependencies": { "@adityahegde/typescript-test-utils": "^1.3.2", @@ -115,7 +117,7 @@ }, "files": [ "dist", - "build-tools/post_install.sh", + "build-tools/post_install.js", "build", "static", "package.json", diff --git a/src/common/data-modeler-state-service/sync-service/EntityStateSyncService.ts b/src/common/data-modeler-state-service/sync-service/EntityStateSyncService.ts index 07065447ae8..63a5f70418d 100644 --- a/src/common/data-modeler-state-service/sync-service/EntityStateSyncService.ts +++ b/src/common/data-modeler-state-service/sync-service/EntityStateSyncService.ts @@ -5,9 +5,9 @@ import type { import type { RootConfig } from "$common/config/RootConfig"; import type { EntityStateService } from "$common/data-modeler-state-service/entity-state-service/EntityStateService"; import type { DataModelerStateService } from "$common/data-modeler-state-service/DataModelerStateService"; -import { execSync } from "node:child_process"; import type { EntityRepository } from "$common/data-modeler-state-service/sync-service/EntityRepository"; import type { EntityStateUpdatesHandler } from "$common/data-modeler-state-service/sync-service/EntityStateUpdatesHandler"; +import { mkdirSync } from "fs"; /** * This class periodically checks source and compares it with in-memory state. @@ -28,7 +28,7 @@ export class EntityStateSyncService< ) {} public async init(): Promise { - execSync(`mkdir -p ${this.config.state.stateFolder}`); + mkdirSync(this.config.state.stateFolder, { recursive: true }); let initialState: EntityState;