refactor: organize dependencies (#3977)

This commit is contained in:
野声 2024-08-30 14:01:40 +08:00 committed by GitHub
parent e16571f310
commit 4b389d9c67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
53 changed files with 325 additions and 211 deletions

View File

@ -1,5 +1,8 @@
node_modules
packages/process/scripts
tools/electron/scripts
**/tools/workspace/**
**/tools/extensions/**
**/tools/**/vendor/
@ -11,7 +14,6 @@ tools/cli-engine/src/browser/worker-host.js
packages/monaco/worker/**
**/typings/**
**/scripts/**
packages/*/lib/**
packages/**/dist/**
packages/**/dist-node/**

View File

@ -234,6 +234,14 @@ module.exports = {
'no-restricted-imports': 0,
},
},
{
files: ['scripts/**'],
rules: {
'no-restricted-imports': 0,
'no-console': 0,
'import/no-relative-packages': 0,
},
},
{
files: ['__tests__/**', 'tests/**'],
plugins: ['jest'],

View File

@ -94,7 +94,7 @@
"compressing": "^1.10.0",
"cross-env": "^7.0.3",
"debug": "^4.3.2",
"depcheck": "^1.4.2",
"depcheck": "^1.4.7",
"eslint": "^8.9.0",
"eslint-config-prettier": "^8.4.0",
"eslint-import-resolver-typescript": "^2.5.0",

View File

@ -27,6 +27,7 @@
"@opensumi/ide-editor": "workspace:*",
"@opensumi/ide-file-search": "workspace:*",
"@opensumi/ide-file-service": "workspace:*",
"@opensumi/ide-monaco": "workspace:*",
"@opensumi/ide-overlay": "workspace:*",
"@opensumi/ide-quick-open": "workspace:*",
"@opensumi/ide-workspace": "workspace:*",

View File

@ -32,14 +32,18 @@
"@opensumi/ide-menu-bar": "workspace:*",
"@opensumi/ide-monaco": "workspace:*",
"@opensumi/ide-overlay": "workspace:*",
"@opensumi/ide-preferences": "workspace:*",
"@opensumi/ide-terminal-next": "workspace:*",
"@opensumi/ide-theme": "workspace:*",
"@opensumi/ide-utils": "workspace:*",
"@opensumi/ide-workspace": "workspace:*",
"ansi-regex": "^2.0.0",
"dom-align": "^1.7.0",
"js-tiktoken": "1.0.12",
"react-chat-elements": "^12.0.10",
"react-highlight": "^0.15.0",
"web-tree-sitter": "0.22.6"
"web-tree-sitter": "0.22.6",
"xterm": "5.3.0"
},
"devDependencies": {
"@opensumi/ide-core-browser": "workspace:*"

View File

@ -26,6 +26,7 @@
"@opensumi/ide-dev-tool": "workspace:*",
"@opensumi/ide-editor": "workspace:*",
"@opensumi/ide-main-layout": "workspace:*",
"@opensumi/ide-monaco": "workspace:*",
"@opensumi/ide-monaco-enhance": "workspace:*",
"@opensumi/ide-theme": "workspace:*",
"@types/react-mentions": "^4.1.13"

View File

@ -16,8 +16,10 @@
},
"dependencies": {
"@ant-design/icons": "^4.6.4",
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-utils": "workspace:*",
"@opensumi/react-custom-scrollbars-2": "^4.3.4",
"@rc-component/mini-decimal": "^1.0.1",
"fuzzy": "^0.1.3",
"lodash": "^4.17.21",
"marked": "4.0.10",

View File

@ -20,6 +20,7 @@
"@furyjs/fury": "0.5.9-beta",
"@opensumi/events": "^1.0.0",
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-utils": "workspace:*",
"@opensumi/reconnecting-websocket": "^4.4.0",
"@opensumi/vscode-jsonrpc": "^8.0.0-next.2",
"path-to-regexp": "^6.2.1",

View File

@ -32,7 +32,6 @@
"mobx": "^6.12.0",
"mobx-react-lite": "^4.0.5",
"react": "^18.2.0",
"react-ctxmenu-trigger": "^1.0.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"react-window": "^1.8.5",

View File

@ -20,6 +20,7 @@
"dependencies": {
"@opensumi/ide-connection": "workspace:*",
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-utils": "workspace:*",
"keytar": "^7.7.0"
},
"devDependencies": {

View File

@ -23,11 +23,13 @@
"@opensumi/ide-file-service": "workspace:*",
"@opensumi/ide-task": "workspace:*",
"@opensumi/ide-terminal-next": "workspace:*",
"@opensumi/ide-utils": "workspace:*",
"@rjsf/core": "5.20.0",
"@rjsf/utils": "5.20.0",
"@rjsf/validator-ajv6": "5.20.0",
"anser": "^2.1.1",
"btoa": "^1.2.1"
"btoa": "^1.2.1",
"react-virtualized-auto-sizer": "^1.0.2"
},
"devDependencies": {
"@opensumi/ide-components": "workspace:*",

View File

@ -19,8 +19,14 @@
"url": "git@github.com:opensumi/core.git"
},
"dependencies": {
"@opensumi/ide-components": "workspace:*",
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-core-node": "workspace:*"
"@opensumi/ide-editor": "workspace:*",
"@opensumi/ide-file-service": "workspace:*",
"@opensumi/ide-main-layout": "workspace:*",
"@opensumi/ide-menu-bar": "workspace:*",
"@opensumi/ide-overlay": "workspace:*",
"@opensumi/ide-theme": "workspace:*"
},
"devDependencies": {
"@opensumi/ide-core-browser": "workspace:*",

View File

@ -17,8 +17,7 @@
"url": "git@github.com:opensumi/core.git"
},
"dependencies": {
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-core-node": "workspace:*"
"@opensumi/ide-core-common": "workspace:*"
},
"devDependencies": {
"@opensumi/ide-core-browser": "workspace:*",

View File

@ -22,6 +22,7 @@
"url": "git@github.com:opensumi/core.git"
},
"dependencies": {
"@opensumi/events": "^1.0.0",
"@opensumi/ide-connection": "workspace:*",
"@opensumi/ide-core-browser": "workspace:*",
"@opensumi/ide-core-node": "workspace:*",
@ -29,10 +30,11 @@
"@opensumi/ide-file-search": "workspace:*",
"@opensumi/ide-file-service": "workspace:*",
"@opensumi/ide-logs": "workspace:*",
"@opensumi/ide-markdown": "workspace:*",
"@opensumi/ide-task": "workspace:*",
"@opensumi/ide-terminal-next": "workspace:*",
"@opensumi/ide-utils": "workspace:*",
"@opensumi/ide-webview": "workspace:*",
"@opensumi/vscode-jsonrpc": "^8.0.0-next.2",
"address": "^1.1.2",
"glob-to-regexp": "0.4.1",
"is-running": "^2.1.0",

View File

@ -21,6 +21,7 @@
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-core-node": "workspace:*",
"@opensumi/ide-logs": "workspace:*",
"@opensumi/ide-utils": "workspace:*",
"@parcel/watcher": "2.1.0",
"file-type": "16.5.4",
"nsfw": "2.2.0",

View File

@ -17,8 +17,7 @@
"url": "git@github.com:opensumi/core.git"
},
"dependencies": {
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-core-node": "workspace:*"
"@opensumi/ide-core-common": "workspace:*"
},
"devDependencies": {
"@opensumi/ide-components": "workspace:*",

View File

@ -16,9 +16,12 @@
"clean": "rimraf worker"
},
"dependencies": {
"@opensumi/ide-components": "workspace:*",
"@opensumi/ide-core-browser": "workspace:*",
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-overlay": "workspace:*",
"@opensumi/ide-theme": "workspace:*",
"@opensumi/ide-utils": "workspace:*",
"@opensumi/monaco-editor-core": "0.47.0-patch.15"
},
"devDependencies": {

View File

@ -24,6 +24,7 @@
"@opensumi/ide-editor": "workspace:*",
"@opensumi/ide-explorer": "workspace:*",
"@opensumi/ide-main-layout": "workspace:*",
"@opensumi/ide-monaco": "workspace:*",
"@opensumi/ide-theme": "workspace:*"
}
}

View File

@ -18,7 +18,8 @@
},
"dependencies": {
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-theme": "workspace:*"
"@opensumi/ide-theme": "workspace:*",
"react-ctxmenu-trigger": "^1.0.0"
},
"devDependencies": {
"@opensumi/ide-components": "workspace:*",

View File

@ -17,7 +17,10 @@
"url": "git@github.com:opensumi/core.git"
},
"dependencies": {
"@opensumi/ide-core-common": "workspace:*"
"@opensumi/events": "^1.0.0",
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-monaco": "workspace:*",
"react-virtualized-auto-sizer": "^1.0.2"
},
"devDependencies": {
"@opensumi/ide-components": "workspace:*",

View File

@ -21,9 +21,11 @@
"dependencies": {
"@opensumi/ide-utils": "workspace:*",
"chalk": "^4.1.2",
"mri": "^1.2.0"
"mri": "^1.2.0",
"node-fetch": "^2.6.7"
},
"devDependencies": {
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-dev-tool": "workspace:*",
"@types/node-fetch": "^2.6.1"
}
}

View File

@ -66,6 +66,7 @@
"@opensumi/ide-ai-native": "workspace:*",
"@opensumi/ide-collaboration": "workspace:*",
"@opensumi/ide-comments": "workspace:*",
"@opensumi/ide-components": "workspace:*",
"@opensumi/ide-core-browser": "workspace:*",
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-core-node": "workspace:*",
@ -74,6 +75,7 @@
"@opensumi/ide-design": "workspace:*",
"@opensumi/ide-editor": "workspace:*",
"@opensumi/ide-explorer": "workspace:*",
"@opensumi/ide-express-file-server": "workspace:*",
"@opensumi/ide-extension": "workspace:*",
"@opensumi/ide-extension-manager": "workspace:*",
"@opensumi/ide-extension-storage": "workspace:*",

View File

@ -17,9 +17,9 @@
"url": "git@github.com:opensumi/core.git"
},
"dependencies": {
"@opensumi/events": "^1.0.0",
"@opensumi/ide-components": "workspace:*",
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-core-node": "workspace:*",
"@opensumi/ide-theme": "workspace:*"
},
"devDependencies": {

View File

@ -18,7 +18,6 @@
},
"dependencies": {
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-core-node": "workspace:*",
"@opensumi/ide-terminal-next": "workspace:*"
},
"devDependencies": {

View File

@ -21,6 +21,7 @@
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-core-node": "workspace:*",
"@opensumi/ide-file-service": "workspace:*",
"@opensumi/ide-utils": "workspace:*",
"node-pty": "1.0.0",
"os-locale": "^4.0.0",
"xterm": "5.3.0",

View File

@ -15,7 +15,9 @@
"url": "git@github.com:opensumi/core.git"
},
"dependencies": {
"@opensumi/ide-core-common": "workspace:*"
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-theme": "workspace:*",
"react-virtualized-auto-sizer": "^1.0.2"
},
"devDependencies": {
"@opensumi/ide-components": "workspace:*",

View File

@ -17,8 +17,7 @@
"url": "git@github.com:opensumi/core.git"
},
"dependencies": {
"@opensumi/ide-core-common": "workspace:*",
"@opensumi/ide-core-node": "workspace:*"
"@opensumi/ide-core-common": "workspace:*"
},
"devDependencies": {
"@opensumi/ide-core-browser": "workspace:*",

View File

@ -1,8 +1,5 @@
import { addNodeDep } from './fn/module';
import { promisify } from 'util';
import * as fs from 'fs';
const folderName = process.argv[2];
const depName = process.argv[3];

View File

@ -1,9 +1,11 @@
import * as glob from 'glob';
import * as path from 'path';
import { run } from './fn/shell';
import * as fs from 'fs-extra';
import { command } from 'execa';
import chalk from 'chalk';
import { command } from 'execa';
import * as fs from 'fs-extra';
import * as glob from 'glob';
import { run } from './fn/shell';
(async () => {
await run('yarn run clean');

View File

@ -1,5 +1,6 @@
import fetch from 'node-fetch';
import { DefaultLogFields } from 'simple-git';
import { ICommitLogFields, PR_STATE } from './types';
const GITHUB_URL = 'https://github.com/opensumi/core';

View File

@ -1,8 +1,9 @@
#!/usr/bin/env node
import chalk from 'chalk';
import { argv } from '../../packages/core-common/src/node/cli';
import { run } from './run';
import chalk from 'chalk';
if (!process.env.GITHUB_TOKEN) {
console.log(chalk.red('Please export your github personal access token as env `GITHUB_TOKEN`'));

View File

@ -1,10 +1,12 @@
import simpleGit from 'simple-git';
import groupBy from 'lodash/groupBy';
import fs from 'fs';
import path from 'path';
import { formatBytes, getType, getChangelog, getNickNameDesc, prettyDate } from './util';
import groupBy from 'lodash/groupBy';
import simpleGit from 'simple-git';
import * as Github from './github';
import { ICommitLogFields } from './types';
import { formatBytes, getChangelog, getNickNameDesc, getType, prettyDate } from './util';
const OTHER_CHANGE_FIELD_KEY = '其他改动';
const RELEASE_VERSION_REGEX = /^v\d+\.\d+\.\d+$/;
@ -56,15 +58,13 @@ function convertToEnglishType(type: string) {
function convertToMarkdown(logs: ICommitLogFields[]) {
const extendedLogs = logs
.map((log) => {
return {
...log,
changelog: getChangelog(log.pullRequestDescription),
type: convertToEnglishType(getType(log.pullRequestDescription) || OTHER_CHANGE_FIELD_KEY),
href: Github.getPullRequestLink(log.pullRequestId),
nickNameDesc: getNickNameDesc(log.author_name, log.loginName),
};
})
.map((log) => ({
...log,
changelog: getChangelog(log.pullRequestDescription),
type: convertToEnglishType(getType(log.pullRequestDescription) || OTHER_CHANGE_FIELD_KEY),
href: Github.getPullRequestLink(log.pullRequestId),
nickNameDesc: getNickNameDesc(log.author_name, log.loginName),
}))
.filter((log) => !!log.changelog);
const prTypedList = groupBy(extendedLogs, 'type');
@ -92,19 +92,18 @@ function convertToMarkdown(logs: ICommitLogFields[]) {
}
return a.localeCompare(b);
})
.map((type) => {
return [`#### ${type}`].concat(
.map((type) =>
[`#### ${type}`].concat(
...(prTypedList[type]
? prTypedList[type].map((commit) => {
return (
? prTypedList[type].map(
(commit) =>
`- ${commit.changelog || commit.message}` +
` [#${commit.pullRequestId}](${commit.href})` +
` by ${commit.nickNameDesc}`
);
})
` by ${commit.nickNameDesc}`,
)
: []),
);
}),
),
),
);
}
@ -115,8 +114,8 @@ function convertToMarkdown(logs: ICommitLogFields[]) {
*/
function readLogs(from: string, to: string) {
return git.log({
from: from,
to: to,
from,
to,
// symmetric revision range cannot works
// symmetric: `${from}...${to}`
});
@ -144,8 +143,8 @@ async function getTagsByV(isRemote?: boolean) {
async function findSymmetricRevision(isRemote: boolean = false) {
const tagList = await getTagsByV(isRemote);
let tagA: string | undefined = undefined;
let tagB: string | undefined = undefined;
let tagA: string | undefined;
let tagB: string | undefined;
for (const tag of tagList) {
if (tagB === undefined && RELEASE_VERSION_REGEX.test(tag)) {
tagB = tag;

View File

@ -1,7 +1,11 @@
/* eslint no-console: 0 */
import { join, relative } from 'path';
import depcheck from 'depcheck';
import chalk from 'chalk';
import { readdirSync, existsSync } from 'fs-extra';
import depcheck from 'depcheck';
import { existsSync, readdirSync } from 'fs-extra';
import { argv } from '../packages/core-common/src/node/cli';
const packagesDir = join(__dirname, '../packages');
@ -22,19 +26,24 @@ const ghostDepsWhiteLists = [
'@opensumi/monaco-editor-core',
'@opensumi/vscode-debugprotocol',
'vscode',
'sumi',
'vscode-textmate',
'react-window',
'react-ctxmenu-trigger',
'vscode-languageserver-types',
'react-is',
'ws',
'koa',
];
const moduleAllowList = {
'core-common': ['electron'],
'file-service': ['@furyjs/fury'],
};
const options = {
ignoreBinPackage: false, // ignore the packages with bin entry
skipMissing: false, // skip calculation of missing dependencies
ignoreDirs: ['bower_components', 'node_modules', 'lib', '__tests__'],
ignoreDirs: ['bower_components', 'node_modules', 'lib', '__tests__', '__test__'],
ignoreMatches: [
// devtool related
'@opensumi/ide-dev-tool',
@ -42,8 +51,9 @@ const options = {
'ts-node',
'webpack-dev-server',
'@types/*',
'tinybench',
],
ignorePatterns: ['__tests__', '__mocks__'],
ignorePatterns: ['__tests__', '__test__', '__mocks__'],
parsers: {
// the target parsers
'**/*.ts': depcheck.parser.typescript,
@ -63,13 +73,16 @@ const options = {
function check(
rootDir: string,
targetModuleName: string,
config = {
unusedDependency: true,
unusedDevDependency: true,
missing: true,
},
) {
return new Promise<void>((resolve) => {
const allowList = moduleAllowList[targetModuleName] || [];
return new Promise<void>((resolve, reject) => {
const cwd = process.cwd();
depcheck(rootDir, options, (unused) => {
if (config.unusedDependency) {
@ -89,18 +102,16 @@ function check(
unused.devDependencies.forEach((dependency) => {
console.log('* ' + dependency);
});
} else {
// console.log(chalk.greenBright('No unused devDependency'));
}
}
let missed = false;
if (config.missing) {
let missingDeps = Object.keys(unused.missing).filter(
(dep) => !ghostDepsWhiteLists.includes(dep) && (!rootDir.endsWith('browser') || !rootDir.endsWith('node')),
);
// 排除自身对模块的引用影响
missingDeps = missingDeps.filter((dep) => {
return !rootDir.endsWith(dep.split('ide-')[1]);
});
missingDeps = missingDeps.filter((dep) => !rootDir.endsWith(dep.split('ide-')[1]));
if (missingDeps.length > 0) {
console.log(chalk.red('Missing dependencies:'));
missingDeps.forEach((dependency) => {
@ -108,13 +119,17 @@ function check(
unused.missing[dependency].forEach((referencePath, index) => {
console.log(` ${index + 1}. ${relative(cwd, referencePath)}`);
});
if (!allowList.includes(dependency)) {
missed = true;
}
});
} else {
// console.log(chalk.greenBright('No missing dependency'));
}
}
resolve();
if (missed) {
reject('has missing dependencies');
} else {
resolve();
}
});
});
}
@ -129,7 +144,12 @@ async function runTaskWithPackages(targetPacks: string[]) {
}
console.log(chalk.greenBright(`--- [Deps check: ${targetModuleName}] ---`));
await check(packageDir);
try {
await check(packageDir, targetModuleName);
} catch (error) {
console.log(chalk.red(`${targetModuleName} has missing dependencies`));
process.exit(1);
}
console.log('');
}
@ -152,13 +172,15 @@ async function bootAll() {
runTaskWithPackages(targetPacks);
}
const targetModule = (argv as any).module as string;
const targetModule = argv.module as string;
// 指定模块加载
if (targetModule) {
console.log(`Single module mode dependency check: ${targetModule}`);
const moduleName = targetModule.replace(/@ali\//, '');
runTaskWithPackages([moduleName]);
const moduleName = targetModule.replace(/@opensumi\//, '');
runTaskWithPackages([moduleName]).catch((err) => {
console.log(chalk.red(`${moduleName} has missing dependencies`));
process.exit(1);
});
} else {
console.log('Project level dependency check');
bootAll();

View File

@ -1,7 +1,9 @@
import { join } from 'path';
import { readdirSync, existsSync } from 'fs-extra';
import { createInterface } from 'readline';
import { existsSync, readdirSync } from 'fs-extra';
import * as semver from 'semver';
import { argv } from '../packages/core-common/src/node/cli';
import Package from './pkg';

View File

@ -1,16 +1,16 @@
// eslint-disable-next-line no-console
import path from 'path';
import fs from 'fs';
import path from 'path';
import { promisify } from 'util';
import chalk from 'chalk';
import Hbs from 'handlebars';
import isGitClean from 'is-git-clean';
import download from 'offline-iconfont';
import chalk from 'chalk';
import { IDE_ICONFONT_CN_CSS } from '../packages/core-browser/src/style/icon/ide-iconfont';
import { defaultIconfont } from '../packages/components/src/icon/iconfont/iconMap';
import { IDE_ICONFONT_CN_CSS } from '../packages/core-browser/src/style/icon/ide-iconfont';
import pkg from '../packages/core-common/package.json';
const targetDir = path.resolve(__dirname, '../packages/components/src/icon/iconfont');

View File

@ -1,14 +1,16 @@
const os = require('os');
const path = require('path');
const querystring = require('querystring');
const rimraf = require('rimraf');
const fs = require('fs-extra');
const pipeline = require('stream').pipeline;
const retry = require('async-retry');
const awaitEvent = require('await-event');
const compressing = require('compressing');
const log = require('debug')('InstallExtension');
const os = require('os');
const fs = require('fs-extra');
const nodeFetch = require('node-fetch');
const awaitEvent = require('await-event');
const pipeline = require('stream').pipeline;
const retry = require('async-retry');
const rimraf = require('rimraf');
const MARKETPLACE_TYPE = {
OPENVSX: 'openvsx',
ALIPAY_CLOUD: 'alipay-cloud',
@ -75,9 +77,7 @@ async function downloadExtension(url, namespace, extensionName) {
const res = await nodeFetch(url, { timeout: 100000, headers });
if (res.status !== 200) {
throw {
message: `${res.status} ${res.statusText}`,
};
throw new Error(`${res.status} ${res.statusText}`);
}
res.body.pipe(tmpStream);
@ -112,7 +112,7 @@ function unzipFile(dist, targetDirName, tmpZipFile) {
stream.resume();
return;
}
let fileName = header.name.replace(sourcePathRegex, '');
const fileName = header.name.replace(sourcePathRegex, '');
if (/\/$/.test(fileName)) {
const targetFileName = path.join(extensionDir, fileName);
fs.mkdirp(targetFileName, (err) => {

View File

@ -1,4 +1,5 @@
const { ESLintUtils } = require('@typescript-eslint/utils');
const { replaceImportDefault } = require('../../ast-grep/replace-import-default');
const pkgName = 'classnames';
@ -19,31 +20,29 @@ const rule = ESLintUtils.RuleCreator.withoutDocs({
fixable: 'code',
schema: [], // No options
},
create: (context) => {
return {
ImportDeclaration(node) {
const { source, specifiers } = node;
if (source.value === pkgName) {
specifiers.forEach((specifier) => {
if (specifier.type === 'ImportDefaultSpecifier' && specifier.local.name !== expectLocalName) {
// 报告问题并提供修复方案
context.report({
node: specifier.local,
messageId: 'unexpectedImportName',
fix: (fixer) => {
const sourceCode = context.getSourceCode();
const source = sourceCode.text;
const result = replaceImportDefault(source, pkgName, expectLocalName);
create: (context) => ({
ImportDeclaration(node) {
const { source, specifiers } = node;
if (source.value === pkgName) {
specifiers.forEach((specifier) => {
if (specifier.type === 'ImportDefaultSpecifier' && specifier.local.name !== expectLocalName) {
// 报告问题并提供修复方案
context.report({
node: specifier.local,
messageId: 'unexpectedImportName',
fix: (fixer) => {
const sourceCode = context.getSourceCode();
const source = sourceCode.text;
const result = replaceImportDefault(source, pkgName, expectLocalName);
return fixer.replaceTextRange(sourceCode.ast.range, result);
},
});
}
});
}
},
};
},
return fixer.replaceTextRange(sourceCode.ast.range, result);
},
});
}
});
}
},
}),
});
module.exports = rule;

View File

@ -1,11 +1,13 @@
import * as path from 'path';
import * as glob from 'glob';
import * as fs from 'fs-extra';
import { packagesDir, toolsDir } from './dir-constants';
import { run } from './shell';
import * as glob from 'glob';
import camelCase from 'lodash/camelCase';
import upperFirst from 'lodash/upperFirst';
import { packagesDir, toolsDir } from './dir-constants';
import { run } from './shell';
const templateDir = path.join(toolsDir, '/template');
const templatePattern = path.join(templateDir, '/**');
@ -48,9 +50,7 @@ export async function createPackage(name: string) {
if (stat.isFile()) {
const buffer = await fs.readFile(filePath, 'utf-8');
const content = replaceList.reduce((ret, [reg, value]) => {
return ret.replace(reg, value);
}, buffer.toString());
const content = replaceList.reduce((ret, [reg, value]) => ret.replace(reg, value), buffer.toString());
const relativePath = path.relative(templateDir, filePath);
const resultPath = path.join(packagesDir, name, relativePath);

View File

@ -1,5 +1,6 @@
import * as path from 'path';
import { packagesDir, packageName } from './dir-constants';
import { packageName, packagesDir } from './dir-constants';
import { run } from './shell';
export function getPkgFromFolder(folderName: string) {
@ -23,5 +24,5 @@ export async function addBrowserDep(depName: string) {
export async function addDep(depName: string, pkgName: string) {
await run(`npx lerna add ${depName} --scope ${pkgName}`);
await run(`yarn run init`);
await run('yarn run init');
}

View File

@ -1,8 +1,11 @@
import { readFileSync, writeFileSync, ensureFileSync } from 'fs-extra';
import { join } from 'path';
import { ensureFileSync, readFileSync, writeFileSync } from 'fs-extra';
import { argv } from '../packages/core-common/src/node/cli';
import { generateManifest } from './manifest';
import Package, { readAllMainPackages } from './pkg';
import { argv } from '../packages/core-common/src/node/cli';
import { join } from 'path';
// yarn run manifest -v=2.19.0
const version = argv.v as string;

View File

@ -1,6 +1,7 @@
import fse from 'fs-extra';
import path from 'path';
import fse from 'fs-extra';
const packagesPath = path.join(__dirname, '../packages');
const referenceDirPath = path.join(__dirname, '../configs/ts/references');
const configJsonPath = path.join(__dirname, '../configs/ts/tsconfig.resolve.json');

View File

@ -1,11 +1,13 @@
import fs from 'fs';
import path from 'path';
import { getPrList } from './changelog/github';
import { formatBytes, getChangelog } from './changelog/util';
import { argv } from '../packages/core-common/src/node/cli';
import chalk from 'chalk';
import { argv } from '../packages/core-common/src/node/cli';
import { getPrList } from './changelog/github';
import { formatBytes, getChangelog } from './changelog/util';
if (!process.env.GITHUB_TOKEN) {
console.log(chalk.red('Please export your github personal access token as env `GITHUB_TOKEN`'));
console.log(chalk.green('You can access your own access token by https://github.com/settings/tokens'));

View File

@ -1,5 +1,6 @@
import * as jest from 'jest';
import { Config } from '@jest/types';
import * as jest from 'jest';
import { argv } from '../../packages/core-common/src/node/cli';
export async function runTest(target: string, options: { project?: string; runInBand?: boolean } = {}) {

View File

@ -1,5 +1,6 @@
import { join } from 'path';
import * as fs from 'fs';
import { join } from 'path';
import Package from './pkg';
/**

View File

@ -1,7 +1,9 @@
import { join } from 'path';
import { readdirSync, existsSync } from 'fs';
import { readJSONSync, readFileSync, writeFileSync } from 'fs-extra';
import { execSync } from 'child_process';
import { existsSync, readdirSync } from 'fs';
import { join } from 'path';
import { readFileSync, readJSONSync, writeFileSync } from 'fs-extra';
import { argv } from '../packages/core-common/src/node/cli';
export default class Package {

View File

@ -1,16 +1,18 @@
/* eslint-disable no-console */
import { join } from 'path';
import { readFileSync, writeFileSync, ensureFileSync } from 'fs-extra';
import { execSync } from 'child_process';
import { join } from 'path';
import { createInterface } from 'readline';
import semver from 'semver';
import { argv } from '../packages/core-common/src/node/cli';
import git from 'git-rev-sync';
import chalk from 'chalk';
import { ensureFileSync, readFileSync, writeFileSync } from 'fs-extra';
import git from 'git-rev-sync';
import semver from 'semver';
import pkg from '../lerna.json';
import Package, { readAllMainPackages } from './pkg';
import { argv } from '../packages/core-common/src/node/cli';
import { generateManifest } from './manifest';
import Package, { readAllMainPackages } from './pkg';
const rl = createInterface({
input: process.stdin,

View File

@ -4,9 +4,10 @@
import { join } from 'path';
import { command } from 'execa';
import { readdirSync, writeJSONSync, mkdirSync, readJSONSync, pathExistsSync, removeSync } from 'fs-extra';
import { pSeries } from '../packages/utils/src/promises';
import { mkdirSync, pathExistsSync, readJSONSync, readdirSync, removeSync, writeJSONSync } from 'fs-extra';
import { parseArgv } from '../packages/utils/src/argv';
import { pSeries } from '../packages/utils/src/promises';
const argv = parseArgv(process.argv.slice(2));
@ -57,61 +58,59 @@ if (argv.noCache) {
const skipList = ((argv as any).skipList ?? '').split(',') || ([] as string[]);
const testResult = {};
const funcs = packagesDirNames.map((target) => {
return async () => {
console.log(`current jest module:`, target);
const result = {};
if (skipList.includes(target)) {
console.log(`${target} is in skip list`);
result['status'] = 'skipped';
testResult[target] = result;
return;
}
await Promise.all(
['jsdom', 'node'].map((v) =>
(async () => {
const checkPointKey = `${target}-${v}`;
if (successCheckPoint.get(checkPointKey)) {
console.log(`${checkPointKey} 命中 successCheckPoint跳过`);
return;
}
const env = {};
if ((argv as any).strictPromise) {
env['EXIT_ON_UNHANDLED_REJECTION'] = 'true';
}
let cmd = `yarn test:module --module=${target} --project=${v}`;
if ((argv as any).serial) {
cmd += ' --no-runInBand';
}
console.log('cmd:', cmd, 'env:', env);
const runResult = await command(cmd, {
reject: false,
stdio: 'inherit',
shell: true,
env,
});
const info = {
info: runResult,
};
if (!runResult.failed) {
successCheckPoint.set(checkPointKey, info);
info['status'] = 'success';
} else {
info['status'] = 'failed';
failCheckPoint.set(checkPointKey, info);
}
result[v] = info;
})(),
),
);
console.log(`end module:`, target);
const funcs = packagesDirNames.map((target) => async () => {
console.log('current jest module:', target);
const result = {};
if (skipList.includes(target)) {
console.log(`${target} is in skip list`);
result['status'] = 'skipped';
testResult[target] = result;
};
return;
}
await Promise.all(
['jsdom', 'node'].map((v) =>
(async () => {
const checkPointKey = `${target}-${v}`;
if (successCheckPoint.get(checkPointKey)) {
console.log(`${checkPointKey} 命中 successCheckPoint跳过`);
return;
}
const env = {};
if ((argv as any).strictPromise) {
env['EXIT_ON_UNHANDLED_REJECTION'] = 'true';
}
let cmd = `yarn test:module --module=${target} --project=${v}`;
if ((argv as any).serial) {
cmd += ' --no-runInBand';
}
console.log('cmd:', cmd, 'env:', env);
const runResult = await command(cmd, {
reject: false,
stdio: 'inherit',
shell: true,
env,
});
const info = {
info: runResult,
};
if (!runResult.failed) {
successCheckPoint.set(checkPointKey, info);
info['status'] = 'success';
} else {
info['status'] = 'failed';
failCheckPoint.set(checkPointKey, info);
}
result[v] = info;
})(),
),
);
console.log('end module:', target);
testResult[target] = result;
});
pSeries(funcs).then(() => {

View File

@ -1,6 +1,7 @@
import { run } from './fn/shell';
import { argv } from '../packages/core-common/src/node/cli';
import { run } from './fn/shell';
const folderName = 'tools/playwright';
(async () => {

View File

@ -1,5 +1,7 @@
import fse from 'fs-extra';
import path from 'path';
import fse from 'fs-extra';
import { startFromFolder } from './fn/module';
import { run } from './fn/shell';

View File

@ -1,6 +1,7 @@
import { startFromFolder } from './fn/module';
import { argv } from '../packages/core-common/src/node/cli';
import { startFromFolder } from './fn/module';
const folderName = (argv.folder as string) || 'packages/startup';
const scriptName = (argv.script as string) || 'start';

View File

@ -1,12 +1,13 @@
const fs = require('fs-extra');
const path = require('path');
const fs = require('fs-extra');
const glob = require('glob');
const dirs = [
// 'browser',
'node',
'common',
]
];
const cwd = process.cwd();
const packages = fs.readdirSync(cwd + '/packages');

View File

@ -1,8 +1,10 @@
import glob from 'glob';
import path from 'path';
import { run } from './fn/shell';
import { copy } from 'fs-extra';
import ParcelWatcher from '@parcel/watcher';
import { copy } from 'fs-extra';
import glob from 'glob';
import { run } from './fn/shell';
let handler: ParcelWatcher.AsyncSubscription;
(async () => {

View File

@ -1978,7 +1978,7 @@ __metadata:
compressing: "npm:^1.10.0"
cross-env: "npm:^7.0.3"
debug: "npm:^4.3.2"
depcheck: "npm:^1.4.2"
depcheck: "npm:^1.4.7"
eslint: "npm:^8.9.0"
eslint-config-prettier: "npm:^8.4.0"
eslint-import-resolver-typescript: "npm:^2.5.0"
@ -2053,6 +2053,7 @@ __metadata:
"@opensumi/ide-editor": "workspace:*"
"@opensumi/ide-file-search": "workspace:*"
"@opensumi/ide-file-service": "workspace:*"
"@opensumi/ide-monaco": "workspace:*"
"@opensumi/ide-overlay": "workspace:*"
"@opensumi/ide-quick-open": "workspace:*"
"@opensumi/ide-workspace": "workspace:*"
@ -2078,14 +2079,18 @@ __metadata:
"@opensumi/ide-menu-bar": "workspace:*"
"@opensumi/ide-monaco": "workspace:*"
"@opensumi/ide-overlay": "workspace:*"
"@opensumi/ide-preferences": "workspace:*"
"@opensumi/ide-terminal-next": "workspace:*"
"@opensumi/ide-theme": "workspace:*"
"@opensumi/ide-utils": "workspace:*"
"@opensumi/ide-workspace": "workspace:*"
ansi-regex: "npm:^2.0.0"
dom-align: "npm:^1.7.0"
js-tiktoken: "npm:1.0.12"
react-chat-elements: "npm:^12.0.10"
react-highlight: "npm:^0.15.0"
web-tree-sitter: "npm:0.22.6"
xterm: "npm:5.3.0"
languageName: unknown
linkType: soft
@ -2119,6 +2124,7 @@ __metadata:
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-editor": "workspace:*"
"@opensumi/ide-main-layout": "workspace:*"
"@opensumi/ide-monaco": "workspace:*"
"@opensumi/ide-monaco-enhance": "workspace:*"
"@opensumi/ide-theme": "workspace:*"
"@types/react-mentions": "npm:^4.1.13"
@ -2131,9 +2137,11 @@ __metadata:
resolution: "@opensumi/ide-components@workspace:packages/components"
dependencies:
"@ant-design/icons": "npm:^4.6.4"
"@opensumi/ide-core-common": "workspace:*"
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-utils": "workspace:*"
"@opensumi/react-custom-scrollbars-2": "npm:^4.3.4"
"@rc-component/mini-decimal": "npm:^1.0.1"
"@types/marked": "npm:^4.0.7"
"@types/react-window": "npm:^1.8.5"
fuzzy: "npm:^0.1.3"
@ -2165,6 +2173,7 @@ __metadata:
"@opensumi/ide-components": "workspace:*"
"@opensumi/ide-core-common": "workspace:*"
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-utils": "workspace:*"
"@opensumi/mock-socket": "npm:^9.3.1"
"@opensumi/reconnecting-websocket": "npm:^4.4.0"
"@opensumi/vscode-jsonrpc": "npm:^8.0.0-next.2"
@ -2191,7 +2200,6 @@ __metadata:
mobx: "npm:^6.12.0"
mobx-react-lite: "npm:^4.0.5"
react: "npm:^18.2.0"
react-ctxmenu-trigger: "npm:^1.0.0"
react-dom: "npm:^18.2.0"
react-is: "npm:^18.2.0"
react-window: "npm:^1.8.5"
@ -2233,6 +2241,7 @@ __metadata:
"@opensumi/ide-connection": "workspace:*"
"@opensumi/ide-core-common": "workspace:*"
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-utils": "workspace:*"
keytar: "npm:^7.7.0"
languageName: unknown
linkType: soft
@ -2260,6 +2269,7 @@ __metadata:
"@opensumi/ide-task": "workspace:*"
"@opensumi/ide-terminal-next": "workspace:*"
"@opensumi/ide-theme": "workspace:*"
"@opensumi/ide-utils": "workspace:*"
"@opensumi/ide-variable": "workspace:*"
"@opensumi/ide-workspace": "workspace:*"
"@opensumi/ide-workspace-edit": "workspace:*"
@ -2269,6 +2279,7 @@ __metadata:
"@types/btoa": "npm:^1.2.3"
anser: "npm:^2.1.1"
btoa: "npm:^1.2.1"
react-virtualized-auto-sizer: "npm:^1.0.2"
languageName: unknown
linkType: soft
@ -2287,10 +2298,16 @@ __metadata:
version: 0.0.0-use.local
resolution: "@opensumi/ide-design@workspace:packages/design"
dependencies:
"@opensumi/ide-components": "workspace:*"
"@opensumi/ide-core-browser": "workspace:*"
"@opensumi/ide-core-common": "workspace:*"
"@opensumi/ide-core-node": "workspace:*"
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-editor": "workspace:*"
"@opensumi/ide-file-service": "workspace:*"
"@opensumi/ide-main-layout": "workspace:*"
"@opensumi/ide-menu-bar": "workspace:*"
"@opensumi/ide-overlay": "workspace:*"
"@opensumi/ide-theme": "workspace:*"
languageName: unknown
linkType: soft
@ -2372,7 +2389,6 @@ __metadata:
dependencies:
"@opensumi/ide-core-browser": "workspace:*"
"@opensumi/ide-core-common": "workspace:*"
"@opensumi/ide-core-node": "workspace:*"
"@opensumi/ide-dev-tool": "workspace:*"
languageName: unknown
linkType: soft
@ -2429,6 +2445,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@opensumi/ide-extension@workspace:packages/extension"
dependencies:
"@opensumi/events": "npm:^1.0.0"
"@opensumi/ide-ai-native": "workspace:*"
"@opensumi/ide-comments": "workspace:*"
"@opensumi/ide-components": "workspace:*"
@ -2447,6 +2464,7 @@ __metadata:
"@opensumi/ide-i18n": "workspace:*"
"@opensumi/ide-logs": "workspace:*"
"@opensumi/ide-main-layout": "workspace:*"
"@opensumi/ide-markdown": "workspace:*"
"@opensumi/ide-monaco": "workspace:*"
"@opensumi/ide-output": "workspace:*"
"@opensumi/ide-overlay": "workspace:*"
@ -2457,10 +2475,10 @@ __metadata:
"@opensumi/ide-testing": "workspace:*"
"@opensumi/ide-theme": "workspace:*"
"@opensumi/ide-toolbar": "workspace:*"
"@opensumi/ide-utils": "workspace:*"
"@opensumi/ide-webview": "workspace:*"
"@opensumi/ide-workspace": "workspace:*"
"@opensumi/ide-workspace-edit": "workspace:*"
"@opensumi/vscode-jsonrpc": "npm:^8.0.0-next.2"
address: "npm:^1.1.2"
glob-to-regexp: "npm:0.4.1"
is-running: "npm:^2.1.0"
@ -2511,6 +2529,7 @@ __metadata:
"@opensumi/ide-core-node": "workspace:*"
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-logs": "workspace:*"
"@opensumi/ide-utils": "workspace:*"
"@parcel/watcher": "npm:2.1.0"
file-type: "npm:16.5.4"
nsfw: "npm:2.2.0"
@ -2600,7 +2619,6 @@ __metadata:
"@opensumi/ide-components": "workspace:*"
"@opensumi/ide-core-browser": "workspace:*"
"@opensumi/ide-core-common": "workspace:*"
"@opensumi/ide-core-node": "workspace:*"
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-editor": "workspace:*"
"@opensumi/ide-webview": "workspace:*"
@ -2649,11 +2667,14 @@ __metadata:
version: 0.0.0-use.local
resolution: "@opensumi/ide-monaco@workspace:packages/monaco"
dependencies:
"@opensumi/ide-components": "workspace:*"
"@opensumi/ide-core-browser": "workspace:*"
"@opensumi/ide-core-common": "workspace:*"
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-file-service": "workspace:*"
"@opensumi/ide-overlay": "workspace:*"
"@opensumi/ide-theme": "workspace:*"
"@opensumi/ide-utils": "workspace:*"
"@opensumi/ide-workspace": "workspace:*"
"@opensumi/monaco-editor-core": "npm:0.47.0-patch.15"
languageName: unknown
@ -2688,6 +2709,7 @@ __metadata:
"@opensumi/ide-editor": "workspace:*"
"@opensumi/ide-explorer": "workspace:*"
"@opensumi/ide-main-layout": "workspace:*"
"@opensumi/ide-monaco": "workspace:*"
"@opensumi/ide-theme": "workspace:*"
languageName: unknown
linkType: soft
@ -2716,6 +2738,7 @@ __metadata:
"@opensumi/ide-core-common": "workspace:*"
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-theme": "workspace:*"
react-ctxmenu-trigger: "npm:^1.0.0"
languageName: unknown
linkType: soft
@ -2723,13 +2746,16 @@ __metadata:
version: 0.0.0-use.local
resolution: "@opensumi/ide-preferences@workspace:packages/preferences"
dependencies:
"@opensumi/events": "npm:^1.0.0"
"@opensumi/ide-components": "workspace:*"
"@opensumi/ide-core-browser": "workspace:*"
"@opensumi/ide-core-common": "workspace:*"
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-editor": "workspace:*"
"@opensumi/ide-file-service": "workspace:*"
"@opensumi/ide-monaco": "workspace:*"
"@opensumi/ide-workspace": "workspace:*"
react-virtualized-auto-sizer: "npm:^1.0.2"
languageName: unknown
linkType: soft
@ -2820,6 +2846,7 @@ __metadata:
"@opensumi/ide-ai-native": "workspace:*"
"@opensumi/ide-collaboration": "workspace:*"
"@opensumi/ide-comments": "workspace:*"
"@opensumi/ide-components": "workspace:*"
"@opensumi/ide-core-browser": "workspace:*"
"@opensumi/ide-core-common": "workspace:*"
"@opensumi/ide-core-node": "workspace:*"
@ -2829,6 +2856,7 @@ __metadata:
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-editor": "workspace:*"
"@opensumi/ide-explorer": "workspace:*"
"@opensumi/ide-express-file-server": "workspace:*"
"@opensumi/ide-extension": "workspace:*"
"@opensumi/ide-extension-manager": "workspace:*"
"@opensumi/ide-extension-storage": "workspace:*"
@ -2900,10 +2928,10 @@ __metadata:
version: 0.0.0-use.local
resolution: "@opensumi/ide-status-bar@workspace:packages/status-bar"
dependencies:
"@opensumi/events": "npm:^1.0.0"
"@opensumi/ide-components": "workspace:*"
"@opensumi/ide-core-browser": "workspace:*"
"@opensumi/ide-core-common": "workspace:*"
"@opensumi/ide-core-node": "workspace:*"
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-theme": "workspace:*"
languageName: unknown
@ -2927,7 +2955,6 @@ __metadata:
dependencies:
"@opensumi/ide-core-browser": "workspace:*"
"@opensumi/ide-core-common": "workspace:*"
"@opensumi/ide-core-node": "workspace:*"
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-editor": "workspace:*"
"@opensumi/ide-output": "workspace:*"
@ -2954,6 +2981,7 @@ __metadata:
"@opensumi/ide-overlay": "workspace:*"
"@opensumi/ide-status-bar": "workspace:*"
"@opensumi/ide-theme": "workspace:*"
"@opensumi/ide-utils": "workspace:*"
"@opensumi/ide-variable": "workspace:*"
"@opensumi/ide-workspace": "workspace:*"
"@types/http-proxy": "npm:^1.17.2"
@ -2982,6 +3010,8 @@ __metadata:
"@opensumi/ide-markdown": "workspace:*"
"@opensumi/ide-monaco": "workspace:*"
"@opensumi/ide-monaco-enhance": "workspace:*"
"@opensumi/ide-theme": "workspace:*"
react-virtualized-auto-sizer: "npm:^1.0.2"
languageName: unknown
linkType: soft
@ -3038,7 +3068,6 @@ __metadata:
"@opensumi/ide-core-browser": "workspace:*"
"@opensumi/ide-core-common": "workspace:*"
"@opensumi/ide-core-electron-main": "workspace:*"
"@opensumi/ide-core-node": "workspace:*"
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-editor": "workspace:*"
"@opensumi/ide-theme": "workspace:*"
@ -3128,8 +3157,10 @@ __metadata:
dependencies:
"@opensumi/ide-dev-tool": "workspace:*"
"@opensumi/ide-utils": "workspace:*"
"@types/node-fetch": "npm:^2.6.1"
chalk: "npm:^4.1.2"
mri: "npm:^1.2.0"
node-fetch: "npm:^2.6.7"
languageName: unknown
linkType: soft
@ -7648,7 +7679,7 @@ __metadata:
languageName: node
linkType: hard
"depcheck@npm:^1.4.2":
"depcheck@npm:^1.4.7":
version: 1.4.7
resolution: "depcheck@npm:1.4.7"
dependencies: