mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
add a script to find ready to migrate to ts project refs plugins (#82305)
This commit is contained in:
parent
e94db6329d
commit
1de0296c4b
2 changed files with 110 additions and 0 deletions
21
scripts/find_plugins_ready_to_migrate_to_ts_refs.js
Normal file
21
scripts/find_plugins_ready_to_migrate_to_ts_refs.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
require('../src/setup_node_env');
|
||||
require('../src/dev/run_find_plugins_ready_migrate_to_ts_refs');
|
89
src/dev/run_find_plugins_ready_migrate_to_ts_refs.ts
Normal file
89
src/dev/run_find_plugins_ready_migrate_to_ts_refs.ts
Normal file
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
import Path from 'path';
|
||||
import Fs from 'fs';
|
||||
import { get } from 'lodash';
|
||||
import { run, KibanaPlatformPlugin } from '@kbn/dev-utils';
|
||||
import { getPluginDeps, findPlugins } from './plugin_discovery';
|
||||
|
||||
interface AllOptions {
|
||||
id?: string;
|
||||
examples?: boolean;
|
||||
extraPluginScanDirs?: string[];
|
||||
}
|
||||
|
||||
run(
|
||||
async ({ flags, log }) => {
|
||||
const { examples = false, extraPluginScanDirs = [] } = flags as AllOptions;
|
||||
|
||||
const pluginMap = findPlugins({
|
||||
oss: false,
|
||||
examples,
|
||||
extraPluginScanDirs,
|
||||
});
|
||||
|
||||
const readyToMigrate = new Set<KibanaPlatformPlugin>();
|
||||
for (const pluginId of pluginMap.keys()) {
|
||||
const { deps, errors } = getPluginDeps({
|
||||
pluginMap,
|
||||
id: pluginId,
|
||||
});
|
||||
|
||||
if (deps.size === 0 && errors.size === 0) {
|
||||
readyToMigrate.add(pluginMap.get(pluginId)!);
|
||||
}
|
||||
}
|
||||
|
||||
const notMigratedPlugins = [...readyToMigrate].filter(
|
||||
(plugin) => !isMigratedToTsProjectRefs(plugin.directory)
|
||||
);
|
||||
if (notMigratedPlugins.length > 0) {
|
||||
log.info(
|
||||
`Dependencies ready to migrate to TS project refs:\n${notMigratedPlugins
|
||||
.map((p) => p.manifest.id)
|
||||
.join('\n')}`
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
flags: {
|
||||
boolean: ['examples'],
|
||||
string: ['id'],
|
||||
default: {
|
||||
examples: false,
|
||||
},
|
||||
allowUnexpected: false,
|
||||
help: `
|
||||
--examples Include examples folder
|
||||
--extraPluginScanDirs Include extra scan folder
|
||||
`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
function isMigratedToTsProjectRefs(dir: string): boolean {
|
||||
try {
|
||||
const path = Path.join(dir, 'tsconfig.json');
|
||||
const content = Fs.readFileSync(path, { encoding: 'utf8' });
|
||||
return get(JSON.parse(content), 'compilerOptions.composite', false);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue