Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update lerna to v7 #3070

Merged
merged 10 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ jobs:
npm i --no-audit -g autocannon zx
# npm run purge # if you want to clean up the cache
npm i --no-audit
npm run bootstrap
- name: Build
run: |
sed -i 's/\(moduleResolution.\+,\)/\1 "incremental": true,/' tsconfig.json
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ jobs:
with:
mongodb-version: 4.2

- run: npm run install_npm
- run: npm install && npm install codecov
- run: npm run bootstrap
- run: npm run build --if-present
- run: npm run cov
env:
Expand Down Expand Up @@ -127,6 +127,5 @@ jobs:
# with:
# node-version: ${{ matrix.node-version }}
# - run: npm install
# - run: npm run bootstrap
# - run: npm run build --if-present
# - run: npm run cov
1 change: 0 additions & 1 deletion .github/workflows/precheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ jobs:
mongodb-version: 4.2

- run: npm install
- run: npm run bootstrap
- run: npm run build --if-present
- run: npm run lint
- run: npm run lint:cycle
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/presite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run bootstrap
- run: npm run build --if-present
- run: cd site && npm install && npm run build
1 change: 0 additions & 1 deletion .github/workflows/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run bootstrap
- run: npm run build --if-present
- name: action-zip
uses: montudor/[email protected]
Expand Down
17 changes: 0 additions & 17 deletions nx.json

This file was deleted.

12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
"@vercel/ncc": "0.36.1",
"autocannon": "7.11.0",
"jest": "29.5.0",
"lerna": "6.5.1",
"lerna": "7.1.1",
"lerna-changelog": "2.2.0",
"madge": "6.1.0",
"mwts": "1.3.0",
"nx": "15.9.4",
"tree-kill": "1.2.2",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
Expand All @@ -23,6 +22,7 @@
"zx": "7.2.3"
},
"scripts": {
"install_npm": "sh scripts/install_npm.sh",
"test": "lerna run test",
"link": "lerna run link",
"cov": "lerna run cov --concurrency 2 --stream",
Expand Down Expand Up @@ -64,5 +64,11 @@
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/midway"
}
},
"workspaces": [
"packages/*",
"packages-serverless/*",
"packages-legacy/*",
"packages-resource/*"
]
}
1 change: 0 additions & 1 deletion packages/info/test/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ exports[`test/index.test.ts should test get config and filter secret 1`] = `
"debug": "{"recordConfigMergeOrder":true}",
"info": "{"title":"Midway Info","infoPath":"/_info","hiddenKey":["k***","****","*****n","********","p****"]}",
"keys": "["1*******5"]",
"midwayLogger": "{"default":{"dir":"logs","level":"info","consoleLevel":"info","auditFileDir":".audit","disableFile":true,"disableError":true},"clients":{"coreLogger":{"level":"info","fileLogName":"midway-core.log"},"appLogger":{"fileLogName":"midway-app.log","aliasName":"logger"}}}",
"oss": "{"clients":{"default":{"accessKeyId":"123","accessKeySecret":"f*****f"}}}",
},
"type": "Midway Config",
Expand Down
4 changes: 3 additions & 1 deletion packages/info/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ describe('test/index.test.ts', () => {
]
});
const infoService = await app.getApplicationContext().getAsync(InfoService);
expect(infoService.midwayConfig()).toMatchSnapshot();
const config = infoService.midwayConfig();
delete config['info']['midwayLogger'];
expect(config).toMatchSnapshot();
});
});
22 changes: 17 additions & 5 deletions packages/mock/src/creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
ComponentModule,
MockAppConfigurationOptions,
IBootstrapAppStarter,
MockBootstrapOptions,
} from './interface';
import {
findFirstExistModule,
Expand Down Expand Up @@ -57,13 +58,18 @@ function formatPath(baseDir, p) {
export async function create<
T extends IMidwayFramework<any, any, any, any, any>
>(
appDir: string = process.cwd(),
options?: MockAppConfigurationOptions,
appDir: string | MockAppConfigurationOptions,
options: MockAppConfigurationOptions = {},
customFramework?: { new (...args): T } | ComponentModule
): Promise<T> {
debug(`[mock]: Create app, appDir="${appDir}"`);
process.env.MIDWAY_TS_MODE = 'true';

if (typeof appDir === 'object') {
options = appDir;
appDir = options.appDir || '';
}

try {
if (appDir) {
// 处理测试的 fixtures
Expand All @@ -76,6 +82,8 @@ export async function create<
`Path "${appDir}" not exists, please check it.`
);
}
} else {
appDir = process.cwd();
}

clearAllLoggers();
Expand Down Expand Up @@ -273,7 +281,7 @@ export async function createFunctionApp<
if (options.entryFile) {
const exportModules: {
getStarter: () => { close: () => void; start: (...args) => any };
} = require(join(baseDir, options.entryFile));
} = require(formatPath(baseDir, options.entryFile));
options.starter = exportModules.getStarter();
}

Expand Down Expand Up @@ -588,9 +596,13 @@ export async function createLightApp(

export async function createBootstrap(
entryFile: string,
options: MockAppConfigurationOptions = {}
options: MockBootstrapOptions = {}
): Promise<IBootstrapAppStarter> {
if (safeRequire('@midwayjs/faas')) {
if (!options.bootstrapMode) {
options.bootstrapMode = safeRequire('@midwayjs/faas') ? 'faas' : 'app';
}

if (options.bootstrapMode === 'faas') {
options.entryFile = entryFile;
const app = await createFunctionApp(process.cwd(), options);
return {
Expand Down
4 changes: 4 additions & 0 deletions packages/mock/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ export interface MockAppConfigurationOptions extends IMidwayBootstrapOptions {
cleanLogsDir?: boolean;
cleanTempDir?: boolean;
ssl?: boolean;
}

export interface MockBootstrapOptions extends MockAppConfigurationOptions {
entryFile?: string;
bootstrapMode?: 'faas' | 'app';
}

export type ComponentModule = {
Expand Down
4 changes: 3 additions & 1 deletion packages/mock/test/new.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ describe('/test/new.test.ts', () => {
});

it('should test with entry file', async () => {
const bootstrap = await createBootstrap(join(__dirname, 'fixtures/base-app-bootstrap', 'bootstrap.js'));
const bootstrap = await createBootstrap(join(__dirname, 'fixtures/base-app-bootstrap', 'bootstrap.js'), {
bootstrapMode: 'app',
});
const app = bootstrap.getApp('koa');

const result = await createHttpRequest(app).get('/').query({ name: 'harry' });
Expand Down
14 changes: 14 additions & 0 deletions scripts/install_npm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e

# 获取node版本
NODE_VERSION=$(node -v | cut -dv -f2 | cut -d. -f1)

# 如果 为 node 14,则重新安装高版本的 npm,并重新安装
if [ "$NODE_VERSION" = "14" ]; then
echo 'npm versin is 14, reinstall npm'
npm install -g npm@8

echo 'npm version'
npm -v
fi
Loading