react-native-macos/scripts/setup-verdaccio.js

50 строки
1.4 KiB
JavaScript
Исходник Обычный вид История

Use verdaccio for the template e2e test (#34577) Summary: This PR adds [verdaccio](https://github.com/verdaccio/verdaccio) to release packages in the `packages` directory during the E2E test on CI. The rationale behind this is the following: - Firstly, we wanted to push the [monorepo RFC](https://github.com/react-native-community/discussions-and-proposals/pull/480). We hit an issue when renaming the packages to follow the same convention caused by the e2e test using the template to fail. This is because the template installs packages from the live version of npm – and if you just rename a package in a given PR without releasing it, the package understandably can't be installed since it's not published, yet – as you can see [here](https://app.circleci.com/pipelines/github/facebook/react-native/15286/workflows/149df51f-f59b-4eb3-b92c-20c513111f04/jobs/282135?invite=true#step-108-283). - Secondly, the current e2e test on `main` does not actually test the latest code of the packages in the `packages` directory as it simply downloads the latest versions from npm. This creates a divide between what's tested and what users should expect when using nightlies or when a new minor is released. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Internal] [Changed] - Use verdaccio for template e2e test Pull Request resolved: https://github.com/facebook/react-native/pull/34577 Test Plan: `test_js` CI check should pass. Additionally, I have temporarily updated the [PR](https://github.com/facebook/react-native/pull/34572) renaming `assets` to `assets-registry` to include the verdaccio changes – the `test_js` passes there, additionally proving merging this PR will unblock us with the rename PRs. Reviewed By: cipolleschi Differential Revision: D39723048 Pulled By: cortinico fbshipit-source-id: aeff3811967360740df3b3dbf1df50e506fb72d8
2022-09-22 15:02:37 +03:00
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
const {execSync, spawn} = require('child_process');
function setupVerdaccio(
reactNativeRootPath, // Path to React Native root folder
verdaccioConfigPath, // Path to Verdaccio config file, which you want to use for bootstrapping Verdaccio
verdaccioStoragePath, // Path to Verdaccio storage, where it should keep packages. Optional. Default value will be decided by your Verdaccio config
) {
if (!reactNativeRootPath) {
throw new Error(
'Path to React Native repo root is not specified. You should provide it as a first argument',
);
}
if (!verdaccioConfigPath) {
throw new Error(
'Path to Verdaccio config is not specified. You should provide it as a second argument',
);
}
execSync('echo "//localhost:4873/:_authToken=secretToken" > .npmrc', {
cwd: reactNativeRootPath,
});
const verdaccioProcess = spawn(
'npx',
['verdaccio@5.16.3', '--config', verdaccioConfigPath],
{env: {...process.env, VERDACCIO_STORAGE_PATH: verdaccioStoragePath}},
);
Use verdaccio for the template e2e test (#34577) Summary: This PR adds [verdaccio](https://github.com/verdaccio/verdaccio) to release packages in the `packages` directory during the E2E test on CI. The rationale behind this is the following: - Firstly, we wanted to push the [monorepo RFC](https://github.com/react-native-community/discussions-and-proposals/pull/480). We hit an issue when renaming the packages to follow the same convention caused by the e2e test using the template to fail. This is because the template installs packages from the live version of npm – and if you just rename a package in a given PR without releasing it, the package understandably can't be installed since it's not published, yet – as you can see [here](https://app.circleci.com/pipelines/github/facebook/react-native/15286/workflows/149df51f-f59b-4eb3-b92c-20c513111f04/jobs/282135?invite=true#step-108-283). - Secondly, the current e2e test on `main` does not actually test the latest code of the packages in the `packages` directory as it simply downloads the latest versions from npm. This creates a divide between what's tested and what users should expect when using nightlies or when a new minor is released. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Internal] [Changed] - Use verdaccio for template e2e test Pull Request resolved: https://github.com/facebook/react-native/pull/34577 Test Plan: `test_js` CI check should pass. Additionally, I have temporarily updated the [PR](https://github.com/facebook/react-native/pull/34572) renaming `assets` to `assets-registry` to include the verdaccio changes – the `test_js` passes there, additionally proving merging this PR will unblock us with the rename PRs. Reviewed By: cipolleschi Differential Revision: D39723048 Pulled By: cortinico fbshipit-source-id: aeff3811967360740df3b3dbf1df50e506fb72d8
2022-09-22 15:02:37 +03:00
const VERDACCIO_PID = verdaccioProcess.pid;
execSync('npx wait-on@6.0.1 http://localhost:4873');
execSync('npm set registry http://localhost:4873');
Use verdaccio for the template e2e test (#34577) Summary: This PR adds [verdaccio](https://github.com/verdaccio/verdaccio) to release packages in the `packages` directory during the E2E test on CI. The rationale behind this is the following: - Firstly, we wanted to push the [monorepo RFC](https://github.com/react-native-community/discussions-and-proposals/pull/480). We hit an issue when renaming the packages to follow the same convention caused by the e2e test using the template to fail. This is because the template installs packages from the live version of npm – and if you just rename a package in a given PR without releasing it, the package understandably can't be installed since it's not published, yet – as you can see [here](https://app.circleci.com/pipelines/github/facebook/react-native/15286/workflows/149df51f-f59b-4eb3-b92c-20c513111f04/jobs/282135?invite=true#step-108-283). - Secondly, the current e2e test on `main` does not actually test the latest code of the packages in the `packages` directory as it simply downloads the latest versions from npm. This creates a divide between what's tested and what users should expect when using nightlies or when a new minor is released. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [Internal] [Changed] - Use verdaccio for template e2e test Pull Request resolved: https://github.com/facebook/react-native/pull/34577 Test Plan: `test_js` CI check should pass. Additionally, I have temporarily updated the [PR](https://github.com/facebook/react-native/pull/34572) renaming `assets` to `assets-registry` to include the verdaccio changes – the `test_js` passes there, additionally proving merging this PR will unblock us with the rename PRs. Reviewed By: cipolleschi Differential Revision: D39723048 Pulled By: cortinico fbshipit-source-id: aeff3811967360740df3b3dbf1df50e506fb72d8
2022-09-22 15:02:37 +03:00
return VERDACCIO_PID;
}
module.exports = setupVerdaccio;