kibana/packages/kbn-styled-components-mapping-cli/src/update_file.ts
Gerard Soldevila 6a7c904f92
SKA: Relocate "platform" packages that remain on /packages (#208704)
## Summary

The `/packages` folder at the root of the Kibana repository used to
contain a lot of packages.
In the context of SKA, they have been gradually moved to various
locations:
* `src/platform/packages`
* `x-pack/platform/packages`
* `src/core/packages`

Currently, only `devOnly: true` packages are left in this folder. This
comprises libraries for CLI scripts as well as testing utilities.

With this PR, we are moving ~half of these packages under
`src/platform/packages/(private|shared)/`.
In particular, we are moving those packages that are being used from
platform and/or solutions.

Since they are `"devOnly": true`, this means they are ONLY used from
tests, cypress tests, storybook configs, ./scripts/ folders inside some
modules, or other non-prod-time logic. Nonetheless, they are effectively
referenced from platform and/or solutions code, hence I decided they
should be placed under `platform` folders.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2025-02-24 11:03:30 +00:00

48 lines
1.9 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import * as fs from 'node:fs/promises';
const babelFilePrefix = `/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
module.exports = {
/**
* Synchronized list of all source files that use styled-components.
* Please keep this list up-to-date when converting component styles
* from styled-components to Emotion.
*
* Babel's MatchPattern can be a regex or a string which follows standard
* Node.js path logic as described here:
* https://babeljs.io/docs/options#matchpattern
*
* Used by \`kbn-babel-preset\` and \`kbn-eslint-config\`.
*/
USES_STYLED_COMPONENTS: [
/src[\\/\\\\]platform[\\/\\\\]packages[\\/\\\\]private[\\/\\\\]kbn-ui-shared-deps-npm[\\/\\\\]/,
/src[\\/\\\\]platform[\\/\\\\]packages[\\/\\\\]private[\\/\\\\]kbn-ui-shared-deps-src[\\/\\\\]/,
`;
const babelFileSuffix = ` ],
};
`;
export const updateFile = async (filePath: string, regexStringArray: string[]) => {
const contents = `${babelFilePrefix}\n ${regexStringArray.join(
',\n '
)},\n${babelFileSuffix}`;
return fs.writeFile(filePath, contents);
};