From a26ad154ed80460d7267ad469c1d964124a48da1 Mon Sep 17 00:00:00 2001 From: Eli Zibin Date: Tue, 10 Dec 2024 16:11:40 -0800 Subject: [PATCH] ci? --- .github/workflows/run-tests.yml | 14 +++++++++++++- packages/core/package.json | 2 +- packages/core/src/postinstall.js | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 packages/core/src/postinstall.js diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 9375bcc4..07ca9c9a 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,8 +12,20 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - uses: actions/cache@v2 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Install Dependencies - run: yarn install + run: yarn install --frozen-lockfile - name: Lint run: yarn lint diff --git a/packages/core/package.json b/packages/core/package.json index 003d36e3..bcaa4dff 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -23,7 +23,7 @@ "build": "rm -rf dist && tsc -p ./tsconfig.build.json", "typecheck": "tsc --noEmit", "test": "jest", - "postinstall": "node ./dist/scripts/create-config.js" + "postinstall": "node ./src/postinstall.js" }, "dependencies": { "@react-native-ama/internal": "~1.1.1" diff --git a/packages/core/src/postinstall.js b/packages/core/src/postinstall.js new file mode 100644 index 00000000..1e591ab3 --- /dev/null +++ b/packages/core/src/postinstall.js @@ -0,0 +1,18 @@ +const path = require('path'); + +// INIT_CWD points to where `npm install` or `yarn install` was invoked +const initCwd = process.env.INIT_CWD || ''; +const packageRoot = __dirname; + +// Detect if this is running as part of the monorepo installation +const isMonorepo = initCwd.includes(path.join(packageRoot, '..', '..')); + +// If running in the monorepo context, skip the postinstall script +if (isMonorepo) { + console.log('Skipping postinstall: Running within monorepo'); + process.exit(0); +} + +// If installed as a standalone dependency, run the postinstall logic +console.log('Running postinstall: User installation'); +require('./../dist/scripts/create-config.js');