diff --git a/.github/actions/setup-node-npm/action.yml b/.github/actions/setup-node-npm/action.yml new file mode 100644 index 000000000..e7e221066 --- /dev/null +++ b/.github/actions/setup-node-npm/action.yml @@ -0,0 +1,57 @@ +name: Set up Node.js and npm +description: > + Installs the latest release of the Node.js version in .nvmrc and npm 12, and + applies the repo's .npmrc supply-chain settings to every npm command in the + job, including the ones run in sub-projects. Jobs that test on another Node + version install and build with this first, then switch Node with + actions/setup-node only to run the tests. + +inputs: + cache: + description: "Package manager to cache downloads for ('npm'), or '' for no cache. The release and GHR backfill jobs use '' so a cache can't affect what gets published." + required: false + default: npm + cache-dependency-path: + description: Lockfile(s) the cache key is computed from. + required: false + default: package-lock.json + +runs: + using: composite + steps: + # .nvmrc gives only the major version. check-latest picks its newest + # release, so CI gets Node.js patches without the file changing. + # By default setup-node also enables the npm cache when package.json's + # devEngines names npm, even with cache: ''. package-manager-cache: false + # turns that off, so only cache: npm enables it. + - name: Set up Node.js (version from .nvmrc) + uses: actions/setup-node@v7 + with: + node-version-file: .nvmrc + check-latest: true + cache: ${{ inputs.cache }} + package-manager-cache: false + cache-dependency-path: ${{ inputs.cache-dependency-path }} + + - name: Install npm and apply the repo's npm settings + shell: bash + env: + # Installs the newest npm of this major version that is at least + # min-release-age days old (see scripts/pick-npm-version.js). + NPM_MAJOR: '12' + run: | + NPM_VERSION=$(node "$GITHUB_WORKSPACE/scripts/pick-npm-version.js" "$NPM_MAJOR") + npm install -g "npm@${NPM_VERSION}" + # Sub-projects read the repo's .npmrc through symlinks. The user config + # also covers projects created during the job, such as + # tests/react-native-metro/.sdk. + cat "$GITHUB_WORKSPACE/.npmrc" >> ~/.npmrc + # In CI, an install script nobody approved or denied fails the install + # instead of only printing a warning. + echo "strict-allow-scripts=true" >> ~/.npmrc + # Forces the public registry even if an .npmrc sets another one. Env + # vars override every .npmrc, but not --registry flags or + # @scope:registry settings (with a lockfile, a scoped registry fails + # the install: allow-remote blocks the mismatched URL). + echo "npm_config_registry=https://registry.npmjs.org/" >> "$GITHUB_ENV" + echo "Node $(node --version), npm $(npm --version)" diff --git a/.github/workflows/ghr_backfill.yml b/.github/workflows/ghr_backfill.yml index fe0141b73..767dbe381 100644 --- a/.github/workflows/ghr_backfill.yml +++ b/.github/workflows/ghr_backfill.yml @@ -35,14 +35,16 @@ jobs: packages: write steps: - name: Checkout branch - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: persist-credentials: false - - name: Set up Node - uses: actions/setup-node@v4 + # No npm cache, so nothing from an earlier run can affect what gets + # published to GHR (same as release.yml). + - name: Set up Node and npm + uses: ./.github/actions/setup-node-npm with: - node-version: 18 + cache: '' - name: Configure GitHub Package Registry auth run: echo "//npm.pkg.github.com/:_authToken=\${NODE_AUTH_TOKEN}" >> ~/.npmrc diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index 70b391e18..05f725b9e 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -15,13 +15,16 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 with: # You should create a personal access token and store it in your repository token: ${{ secrets.CI_USER_TOKEN }} repository: 'optimizely/travisci-tools' path: 'home/runner/travisci-tools' ref: 'master' + # Don't leave the PAT on disk. The trigger scripts call the GitHub API + # with curl and the token from env, not through git. + persist-credentials: false - name: set SDK Branch if PR env: HEAD_REF: ${{ github.head_ref }} diff --git a/.github/workflows/javascript.yml b/.github/workflows/javascript.yml index 52aba18d8..cc144f195 100644 --- a/.github/workflows/javascript.yml +++ b/.github/workflows/javascript.yml @@ -6,6 +6,14 @@ on: pull_request: branches: [ master ] +# Every job installs and builds with the Node version in .nvmrc and npm 12 from +# .github/actions/setup-node-npm, which also applies the .npmrc supply-chain +# settings. Jobs that test other Node versions switch Node only to +# run the tests. +# +# Checkouts use persist-credentials: false so the token isn't left on disk for +# later steps. No job runs authenticated git commands after checkout. + jobs: lint_markdown_files: uses: optimizely/javascript-sdk/.github/workflows/lint_markdown.yml@master @@ -13,72 +21,66 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up Node - uses: actions/setup-node@v3 + - uses: actions/checkout@v7 with: - node-version: 16 - cache-dependency-path: ./package-lock.json - cache: 'npm' + persist-credentials: false + - uses: ./.github/actions/setup-node-npm + - name: Install dependencies + run: npm ci - name: Run linting - working-directory: . - run: | - npm install - npm run lint + run: npm run lint typescript_test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up Node - uses: actions/setup-node@v3 + - uses: actions/checkout@v7 with: - node-version: 20 - cache-dependency-path: ./package-lock.json - cache: 'npm' + persist-credentials: false + - uses: ./.github/actions/setup-node-npm + with: + cache-dependency-path: | + package-lock.json + examples/typescript/package-lock.json + - name: Install dependencies + run: npm ci - name: Run TypeScript example - working-directory: . - run: | - npm install - npm run test-typescript + run: npm run test-typescript commonjs_test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up Node 20 (build) - uses: actions/setup-node@v3 + - uses: actions/checkout@v7 with: - node-version: 20 - cache-dependency-path: ./package-lock.json - cache: 'npm' - - name: Build and pack SDK + persist-credentials: false + - uses: ./.github/actions/setup-node-npm + - name: Build, pack, and install the SDK in the example run: | - npm install + npm ci npm pack + npm run test-commonjs -- --skip-build --skip-run - name: Set up Node 18 (runtime test) - uses: actions/setup-node@v3 + uses: actions/setup-node@v7 with: - node-version: '18' + node-version: 18 - name: Run CommonJS example - run: npm run test-commonjs -- --skip-build + working-directory: examples/node-commonjs + run: npm start react_native_metro_test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up Node - uses: actions/setup-node@v3 + - uses: actions/checkout@v7 + with: + persist-credentials: false + - uses: ./.github/actions/setup-node-npm with: - node-version: 22 cache-dependency-path: | - ./package-lock.json - ./tests/react-native-metro/fixtures/*/package-lock.json - cache: 'npm' + package-lock.json + tests/react-native-metro/fixtures/*/package-lock.json + - name: Install dependencies + run: npm ci - name: Run React Native Metro tests - run: | - npm install - npm run test-rn-metro + run: npm run test-rn-metro integration_tests: uses: optimizely/javascript-sdk/.github/workflows/integration_test.yml@master @@ -106,19 +108,17 @@ jobs: USE_LOCAL_BROWSER: 'false' TEST_BROWSER: ${{ matrix.browser }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 + with: + persist-credentials: false # Browser and UMD tests run from tests/browser (see its README), which needs Node 22.23.4+. - - name: Set up Node - uses: actions/setup-node@v3 + - uses: ./.github/actions/setup-node-npm with: - node-version: 22 - cache: 'npm' cache-dependency-path: | - ./package-lock.json - ./tests/browser/package-lock.json + package-lock.json + tests/browser/package-lock.json - name: Install SDK dependencies - working-directory: . - run: npm install + run: npm ci - name: Install browser test dependencies id: browser-deps working-directory: ./tests/browser @@ -137,40 +137,52 @@ jobs: generate_messages_test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up Node - uses: actions/setup-node@v3 + - uses: actions/checkout@v7 with: - node-version: 20 - cache-dependency-path: ./package-lock.json - cache: 'npm' + persist-credentials: false + - uses: ./.github/actions/setup-node-npm + - name: Install dependencies + run: npm ci - name: Test generate-messages script - run: | - npm install - node scripts/test-generate-messages.js + run: node scripts/test-generate-messages.js unit_tests: runs-on: ubuntu-latest strategy: matrix: node: ['18', '20', '22', '24'] + env: + # The Coveralls action, for the Coveralls Parallel step below and the + # finish job. It's a third-party action, so it's pinned to a full commit + # SHA: a tag can be moved to other code (as in the 2025 + # tj-actions/changed-files attack), and both steps get the GITHUB_TOKEN. + # GitHub's own actions (actions/*) use tags. Nothing updates the pin + # automatically. To upgrade, use the commit SHA of the new release tag and + # update the version comment. + # `uses:` doesn't accept ${{ }} expressions, so the steps can't read this + # env var. They reuse the value through the YAML anchor &coveralls-action. + COVERALLS_ACTION: &coveralls-action coverallsapp/github-action@8d6379e14d29928660c4ba802d8e85393440b329 # v2.3.8 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 + with: + persist-credentials: false + # Install with the Node version in .nvmrc and npm 12, then run the tests on + # the matrix version. + - uses: ./.github/actions/setup-node-npm + - name: Install dependencies + run: npm ci - name: Set up Node ${{ matrix.node }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v7 with: node-version: ${{ matrix.node }} - cache: 'npm' - cache-dependency-path: ./package-lock.json + check-latest: true - name: Unit tests - working-directory: . - run: | - npm install - npm run coveralls + run: npm run coveralls + # The pinned Coveralls action from this job's env (see the comment there). - name: Coveralls Parallel - uses: coverallsapp/github-action@master + uses: *coveralls-action with: - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: ./coverage/lcov.info flag-name: run-${{ matrix.node }} # This is a parallel build so need this @@ -184,11 +196,12 @@ jobs: needs: unit_tests runs-on: ubuntu-latest steps: + # The pinned Coveralls action from the unit_tests job's env (see the + # comment there). - name: Coveralls Finished - uses: coverallsapp/github-action@master + uses: *coveralls-action with: github-token: ${{ secrets.github_token }} path-to-lcov: ./coverage/lcov.info parallel-finished: true base-path: . - \ No newline at end of file diff --git a/.github/workflows/lint_markdown.yml b/.github/workflows/lint_markdown.yml index af23e15a4..ca7071786 100644 --- a/.github/workflows/lint_markdown.yml +++ b/.github/workflows/lint_markdown.yml @@ -6,7 +6,9 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 + with: + persist-credentials: false - name: Set up Ruby uses: ruby/setup-ruby@v1 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8b79c33b8..d8b7c680f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,17 +18,18 @@ jobs: environment: npm steps: - name: Checkout branch - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: persist-credentials: false - - name: Setup Node - uses: actions/setup-node@v4 + # The Node version in .nvmrc and npm 12 (new enough for OIDC trusted + # publishing), with the .npmrc supply-chain settings. cache: '' means no + # npm cache, so nothing from an earlier run (e.g. a pull request) can + # affect what gets published. + - name: Set up Node and npm + uses: ./.github/actions/setup-node-npm with: - node-version: 22 - - - name: Upgrade npm for OIDC support - run: npm install -g npm@latest + cache: '' # Configure auth for GHR only. npm registry auth is handled by OIDC # (no .npmrc token entry needed — omitting registry-url from setup-node @@ -41,6 +42,11 @@ jobs: - name: Install dependencies run: npm ci --ignore-scripts + # Don't build the published artifact from packages whose registry + # signatures don't verify. + - name: Verify package signatures + run: npm audit signatures + # Test, build, and pack a single tarball. Both registries publish this # same artifact, so npm and GHR receive byte-identical bytes and the test # suite runs only once. --ignore-scripts on pack avoids a rebuild. diff --git a/.npmrc b/.npmrc new file mode 100644 index 000000000..d22c988d1 --- /dev/null +++ b/.npmrc @@ -0,0 +1,23 @@ +# Supply-chain settings. They need npm 12, which package.json asks for in +# "devEngines": older versions print a warning on every npm command, and ignore +# some or all of these settings. CI installs npm 12: see +# .github/actions/setup-node-npm. +# +# npm only reads the .npmrc in the project's own folder, so every sub-project +# (tests/browser, examples/*, tests/react-native-metro/fixtures/*) has an +# .npmrc that is a symlink to this file. Add one for any new package.json. + +# Don't install a version published less than 7 days ago. Malicious versions +# are usually found and unpublished within that time. +min-release-age=7 + +# No dependencies from git repositories or tarball URLs, only from the registry. +allow-git=none +allow-remote=none + +# Treat unknown keys in .npmrc files as errors instead of ignoring them, so a +# typo can't silently turn off one of the settings above. +strict-npmrc=true + +# Install scripts of dependencies only run if they are approved in the +# "allowScripts" field of package.json (npm approve-scripts / npm deny-scripts). diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..2bd5a0a98 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22 diff --git a/examples/node-commonjs/.npmrc b/examples/node-commonjs/.npmrc new file mode 120000 index 000000000..cba44bb38 --- /dev/null +++ b/examples/node-commonjs/.npmrc @@ -0,0 +1 @@ +../../.npmrc \ No newline at end of file diff --git a/examples/node-commonjs/package.json b/examples/node-commonjs/package.json index ef436bad9..a9f0f78a0 100644 --- a/examples/node-commonjs/package.json +++ b/examples/node-commonjs/package.json @@ -5,5 +5,12 @@ "description": "CommonJS example for Optimizely SDK - verifies CJS compatibility", "scripts": { "start": "node index.js" + }, + "devEngines": { + "packageManager": { + "name": "npm", + "version": ">=12.0.0", + "onFail": "warn" + } } } diff --git a/examples/typescript/.npmrc b/examples/typescript/.npmrc new file mode 120000 index 000000000..cba44bb38 --- /dev/null +++ b/examples/typescript/.npmrc @@ -0,0 +1 @@ +../../.npmrc \ No newline at end of file diff --git a/examples/typescript/package-lock.json b/examples/typescript/package-lock.json index 907f416c9..eed17a12f 100644 --- a/examples/typescript/package-lock.json +++ b/examples/typescript/package-lock.json @@ -13,7 +13,9 @@ } }, "node_modules/@types/node": { - "version": "20.19.28", + "version": "20.19.43", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.43.tgz", + "integrity": "sha512-6oYBAi5ikg4Pl+kGsoYtawUMBT2zZMCvPNF7pVLnHZfd1zf38DRiWn/gT01RYCdUqkv7Fhr+C9ot4/tb+2sVvA==", "dev": true, "license": "MIT", "dependencies": { @@ -22,6 +24,8 @@ }, "node_modules/typescript": { "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "dev": true, "license": "Apache-2.0", "bin": { @@ -34,6 +38,8 @@ }, "node_modules/undici-types": { "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "dev": true, "license": "MIT" } diff --git a/examples/typescript/package.json b/examples/typescript/package.json index bbe7c0bdb..b16930297 100644 --- a/examples/typescript/package.json +++ b/examples/typescript/package.json @@ -12,5 +12,17 @@ "devDependencies": { "@types/node": "^20.0.0", "typescript": "^4.7.4" + }, + "devEngines": { + "runtime": { + "name": "node", + "version": "^22.22.2 || ^24.15.0 || >=26.0.0", + "onFail": "warn" + }, + "packageManager": { + "name": "npm", + "version": ">=12.0.0", + "onFail": "warn" + } } } diff --git a/package.json b/package.json index c5e0bf1bf..57727a5f5 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,18 @@ "engines": { "node": ">=18.0.0" }, + "devEngines": { + "runtime": { + "name": "node", + "version": "^22.22.2 || ^24.15.0 || >=26.0.0", + "onFail": "warn" + }, + "packageManager": { + "name": "npm", + "version": ">=12.0.0", + "onFail": "warn" + } + }, "keywords": [ "optimizely" ], @@ -170,5 +182,9 @@ ], "nyc": { "temp-dir": "coverage/raw" + }, + "allowScripts": { + "esbuild": false, + "fsevents": false } } diff --git a/scripts/README.md b/scripts/README.md index 43906185c..7d71ce7a5 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -123,6 +123,15 @@ Tests cover: - Multi-platform file imports (strictest rules) - `__platforms` extraction +## pick-npm-version.js + +Prints the newest npm release of a major version that is at least a minimum number of days old. CI uses it to choose the npm it installs, because the npm that comes with Node.js doesn't support the `min-release-age` setting in `.npmrc`. If you don't pass a minimum age, the script uses the `min-release-age` value from the repo's `.npmrc`, or 7 days if `.npmrc` doesn't set it. Pre-releases and deprecated versions are skipped. + +```bash +node scripts/pick-npm-version.js 12 # minimum age from min-release-age in .npmrc +node scripts/pick-npm-version.js 12 10 # at least 10 days old +``` + --- See [../docs/PLATFORM_ISOLATION.md](../docs/PLATFORM_ISOLATION.md) for detailed documentation on platform isolation rules. diff --git a/scripts/pick-npm-version.js b/scripts/pick-npm-version.js new file mode 100755 index 000000000..94c7fd989 --- /dev/null +++ b/scripts/pick-npm-version.js @@ -0,0 +1,92 @@ +#!/usr/bin/env node + +/** + * Copyright 2026, Optimizely + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Prints the newest npm .x release that is at least days old. +// +// CI installs npm using the npm that comes with Node.js, which doesn't support the +// min-release-age setting in .npmrc, so this applies the same rule to npm itself. The +// minimum age defaults to min-release-age in the repo's .npmrc, or 7 days if that +// isn't set. Pre-releases and +// deprecated versions are skipped. +// +// Usage: node scripts/pick-npm-version.js [min-age-days] + +const fs = require('fs'); +const path = require('path'); + +const REGISTRY = 'https://registry.npmjs.org'; +const DAY_MS = 24 * 60 * 60 * 1000; +// Used if .npmrc has no min-release-age, so a missing setting doesn't let CI +// install an npm release published minutes ago. +const DEFAULT_MIN_AGE_DAYS = 7; + +function readMinReleaseAge() { + const npmrc = fs.readFileSync(path.join(__dirname, '..', '.npmrc'), 'utf8'); + const match = npmrc.match(/^\s*min-release-age\s*=\s*(\d+)\s*$/m); + if (!match) { + console.error(`min-release-age is not set in .npmrc; using ${DEFAULT_MIN_AGE_DAYS} days.`); + return DEFAULT_MIN_AGE_DAYS; + } + return Number(match[1]); +} + +function compareVersions(a, b) { + const pa = a.split('.').map(Number); + const pb = b.split('.').map(Number); + for (let i = 0; i < 3; i++) { + if (pa[i] !== pb[i]) { + return pa[i] - pb[i]; + } + } + return 0; +} + +async function main() { + const [majorArg, minAgeArg] = process.argv.slice(2); + if (!/^\d+$/.test(majorArg || '') || (minAgeArg !== undefined && !/^\d+$/.test(minAgeArg))) { + console.error('Usage: node scripts/pick-npm-version.js [min-age-days]'); + process.exit(2); + } + const major = Number(majorArg); + const minAgeDays = minAgeArg !== undefined ? Number(minAgeArg) : readMinReleaseAge(); + const cutoff = Date.now() - minAgeDays * DAY_MS; + + // The full metadata document: the abbreviated one has no publish times. + const response = await fetch(`${REGISTRY}/npm`, { headers: { accept: 'application/json' } }); + if (!response.ok) { + throw new Error(`GET ${REGISTRY}/npm failed: ${response.status} ${response.statusText}`); + } + const { versions, time } = await response.json(); + + const candidates = Object.keys(versions) + .filter((version) => /^\d+\.\d+\.\d+$/.test(version) && Number(version.split('.')[0]) === major) + .filter((version) => !versions[version].deprecated) + .filter((version) => time[version] && Date.parse(time[version]) <= cutoff) + .sort(compareVersions); + + if (candidates.length === 0) { + console.error(`No npm ${major}.x release is at least ${minAgeDays} day(s) old.`); + process.exit(1); + } + console.log(candidates[candidates.length - 1]); +} + +main().catch((error) => { + console.error(error.message); + process.exit(1); +}); diff --git a/scripts/run-cjs-example.js b/scripts/run-cjs-example.js index 60d275549..7717a9fd9 100644 --- a/scripts/run-cjs-example.js +++ b/scripts/run-cjs-example.js @@ -67,8 +67,13 @@ function findTarball() { return tarballPath; } +// Options: +// --skip-build use the tarball an earlier `npm pack` created instead of installing and packing +// --skip-run install the SDK in the example but don't run it. CI installs with Node 22 (and the +// pinned npm), then switches Node and runs `npm start` in examples/node-commonjs. function main() { const skipBuild = process.argv.includes('--skip-build'); + const skipRun = process.argv.includes('--skip-run'); console.log('=== Building SDK and Running CommonJS Example ===\n'); @@ -90,14 +95,16 @@ function main() { console.log('\nInstalling SDK tarball in cjs-example...'); run(`npm install --no-save --no-package-lock ${tarballPath}`, exampleDir); - console.log('\nRunning cjs-example...'); - run('npm start', exampleDir); + if (!skipRun) { + console.log('\nRunning cjs-example...'); + run('npm start', exampleDir); + } console.log('\nCleaning up tarball...'); fs.unlinkSync(tarballPath); console.log(`Removed: ${path.basename(tarballPath)}`); - console.log('\n=== Example completed successfully! ===\n'); + console.log(skipRun ? '\n=== SDK installed in cjs-example (not run: --skip-run) ===\n' : '\n=== Example completed successfully! ===\n'); } main(); diff --git a/scripts/run-ts-example.js b/scripts/run-ts-example.js index ee1c7255d..824ac791b 100755 --- a/scripts/run-ts-example.js +++ b/scripts/run-ts-example.js @@ -111,7 +111,7 @@ async function main() { console.log(`Created: ${packOutput}`); console.log('\nInstalling ts-example devDependencies...'); - run('npm install', exampleDir); + run('npm ci', exampleDir); console.log('\nInstalling SDK tarball in ts-example...'); run(`npm install --no-save --no-package-lock ${tarballPath}`, exampleDir); diff --git a/tests/browser/.npmrc b/tests/browser/.npmrc new file mode 120000 index 000000000..cba44bb38 --- /dev/null +++ b/tests/browser/.npmrc @@ -0,0 +1 @@ +../../.npmrc \ No newline at end of file diff --git a/tests/browser/package.json b/tests/browser/package.json index 218f55578..8e67c27c5 100644 --- a/tests/browser/package.json +++ b/tests/browser/package.json @@ -5,6 +5,18 @@ "engines": { "node": "^22.23.4 || ^24.22.1 || >=26.12.1" }, + "devEngines": { + "runtime": { + "name": "node", + "version": "^22.23.4 || ^24.22.1 || >=26.12.1", + "onFail": "warn" + }, + "packageManager": { + "name": "npm", + "version": ">=12.0.0", + "onFail": "warn" + } + }, "scripts": { "test-browser": "node ./run.js browser", "test-browser-local": "USE_LOCAL_BROWSER=true node ./run.js browser", @@ -23,5 +35,10 @@ }, "overrides": { "lightningcss": "$lightningcss" + }, + "allowScripts": { + "edgedriver": false, + "geckodriver": false, + "fsevents": false } } diff --git a/tests/react-native-metro/fixtures/rn-0.73/.npmrc b/tests/react-native-metro/fixtures/rn-0.73/.npmrc new file mode 120000 index 000000000..02b5a689b --- /dev/null +++ b/tests/react-native-metro/fixtures/rn-0.73/.npmrc @@ -0,0 +1 @@ +../../../../.npmrc \ No newline at end of file diff --git a/tests/react-native-metro/fixtures/rn-0.73/package.json b/tests/react-native-metro/fixtures/rn-0.73/package.json index f729bc581..efae91af4 100644 --- a/tests/react-native-metro/fixtures/rn-0.73/package.json +++ b/tests/react-native-metro/fixtures/rn-0.73/package.json @@ -9,5 +9,20 @@ "fast-text-encoding": "1.0.6", "metro": "0.80.12", "metro-config": "0.80.12" + }, + "allowScripts": { + "fsevents": false + }, + "devEngines": { + "runtime": { + "name": "node", + "version": "^22.22.2 || ^24.15.0 || >=26.0.0", + "onFail": "warn" + }, + "packageManager": { + "name": "npm", + "version": ">=12.0.0", + "onFail": "warn" + } } } diff --git a/tests/react-native-metro/fixtures/rn-0.87/.npmrc b/tests/react-native-metro/fixtures/rn-0.87/.npmrc new file mode 120000 index 000000000..02b5a689b --- /dev/null +++ b/tests/react-native-metro/fixtures/rn-0.87/.npmrc @@ -0,0 +1 @@ +../../../../.npmrc \ No newline at end of file diff --git a/tests/react-native-metro/fixtures/rn-0.87/package.json b/tests/react-native-metro/fixtures/rn-0.87/package.json index 2497bab0c..ee934b75c 100644 --- a/tests/react-native-metro/fixtures/rn-0.87/package.json +++ b/tests/react-native-metro/fixtures/rn-0.87/package.json @@ -9,5 +9,17 @@ "fast-text-encoding": "1.0.6", "metro": "0.87.1", "metro-config": "0.87.1" + }, + "devEngines": { + "runtime": { + "name": "node", + "version": "^22.22.2 || ^24.15.0 || >=26.0.0", + "onFail": "warn" + }, + "packageManager": { + "name": "npm", + "version": ">=12.0.0", + "onFail": "warn" + } } }