Skip to content

Commit

Permalink
Skipping playwright browser install (#344)
Browse files Browse the repository at this point in the history
* Skipping playwright browser install

* Switching to nodejs for post_install

* Fixing windows edge cases

* Enabling only for tagged builds
  • Loading branch information
AdityaHegde authored Jun 6, 2022
1 parent 391d27f commit e1d4c4d
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 13 deletions.
13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -88,6 +90,8 @@ jobs:
skip_cleanup: true
on:
tags: true
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=true

- stage: publish
name: "Build & Publish linux binary"
Expand All @@ -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
23 changes: 23 additions & 0 deletions build-tools/post_install.js
Original file line number Diff line number Diff line change
@@ -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"}
);
}
7 changes: 0 additions & 7 deletions build-tools/post_install.sh

This file was deleted.

12 changes: 12 additions & 0 deletions build-tools/replace_package_type.js
Original file line number Diff line number Diff line change
@@ -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);
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -115,7 +117,7 @@
},
"files": [
"dist",
"build-tools/post_install.sh",
"build-tools/post_install.js",
"build",
"static",
"package.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -28,7 +28,7 @@ export class EntityStateSyncService<
) {}

public async init(): Promise<void> {
execSync(`mkdir -p ${this.config.state.stateFolder}`);
mkdirSync(this.config.state.stateFolder, { recursive: true });

let initialState: EntityState<Entity>;

Expand Down

0 comments on commit e1d4c4d

Please sign in to comment.