From 1f715320584ba152da4e08a5509050eee8842aa1 Mon Sep 17 00:00:00 2001 From: pankaj443 Date: Mon, 14 Aug 2023 15:51:12 +0530 Subject: [PATCH] add bash script --- .github/workflows/build.yml | 9 ++++++ scripts/build.sh | 60 +++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100755 scripts/build.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..b69304d58 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,9 @@ +name: Lint +on: push +jobs: + lint: + name: Build + runs-on: macos-latest + steps: + - uses: actions/checkout@v1 + - run: ./scripts/build.sh diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 000000000..9d4a2a821 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,60 @@ +mkdir temp && cd temp + +npm init -y + +npm install --save-dev @percy/cli + +npm install -g pkg + +cd .. + +yarn install + +cp -R ./temp//node_modules/@percy/* packages/ + +sed -i '' '/"type": "module",/d' ./package.json + +cd packages && sed -i '' '/"type": "module",/d' ./*/package.json && cd .. + +echo "import { cli } from '@percy/cli';\n$(cat ./packages/cli/dist/percy.js)" > ./packages/cli/dist/percy.js + +sed -i '' '/Imports and returns compatibile CLI commands from various sources/a \ +function formatFilepath(filepath) {\ + let path = url.pathToFileURL(filepath).href.replace("file:///","");\ + if (!path.includes("C:")) {\ + path = "/" + path;\ + }\ + return path;\ +} +' ./packages/cli/dist/commands.js + +sed -i '' 's/import(url.pathToFileURL(modulePath).href);/import(formatFilepath(modulePath));/g' ./packages/cli/dist/commands.js + +echo "import { execSync } from 'child_process';\n$(cat ./packages/core/dist/install.js)" > ./packages/core/dist/install.js + +sed -i '' '/extract the downloaded file/a \ + var output = execSync(command, { encoding: "utf-8" }).trim();\ + archive = output.concat("/", archive);\ + outdir = output.concat("/", outdir); +' ./packages/core/dist/install.js + +sed -i '' '/let archive/a \ + var command = "pwd";\ + if (archive.includes("C:")) {\ + command = "cd";\ + }\ + outdir = outdir.replace("C:\\\\","");\ + archive = archive.replace("C:\\\\",""); +' ./packages/core/dist/install.js + +sed -i '' '/let outdir/a \ + if (outdir.charAt(0) == "/") {\ + outdir = outdir.replace("/", "");\ + } +' ./packages/core/dist/install.js + +npm run build_cjs + +cp -R ./build/* packages/ + +pkg ./packages/cli/bin/run.js -d \ No newline at end of file