mirror of
https://github.com/logto-io/logto.git
synced 2024-12-30 20:33:54 -05:00
Merge pull request #2143 from logto-io/gao-fix-dev-script
refactor: fix dev script
This commit is contained in:
commit
5cf97af865
13 changed files with 34 additions and 28 deletions
1
packages/cli/.gitignore
vendored
1
packages/cli/.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
alteration-scripts/
|
||||
src/package-json.ts
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
},
|
||||
"scripts": {
|
||||
"precommit": "lint-staged",
|
||||
"build": "rimraf lib && tsc -p tsconfig.build.json",
|
||||
"prepare:package-json": "node -p \"'export const packageJson = ' + JSON.stringify(require('./package.json'), undefined, 2) + ';'\" > src/package-json.ts",
|
||||
"build": "rimraf lib && pnpm prepare:package-json && tsc -p tsconfig.build.json",
|
||||
"start": "node .",
|
||||
"start:dev": "ts-node --files src/index.ts",
|
||||
"lint": "eslint --ext .ts src",
|
||||
|
@ -83,7 +84,8 @@
|
|||
"error",
|
||||
7
|
||||
]
|
||||
}
|
||||
},
|
||||
"ignorePatterns": ["src/package-json.ts"]
|
||||
},
|
||||
"prettier": "@silverhand/eslint-config/.prettierrc"
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import { findPackage } from '@logto/shared';
|
|||
import { conditionalString } from '@silverhand/essentials';
|
||||
import chalk from 'chalk';
|
||||
import { copy, existsSync, remove, readdir } from 'fs-extra';
|
||||
import { SemVer } from 'semver';
|
||||
import { DatabasePool } from 'slonik';
|
||||
import { CommandModule } from 'yargs';
|
||||
|
||||
|
@ -30,12 +29,6 @@ const getTimestampFromFilename = (filename: string) => {
|
|||
return Number(match[1]);
|
||||
};
|
||||
|
||||
const getVersionFromFilename = (filename: string) => {
|
||||
try {
|
||||
return new SemVer(filename.split('-')[0]?.replaceAll('_', '-') ?? 'unknown');
|
||||
} catch {}
|
||||
};
|
||||
|
||||
const importAlterationScript = async (filePath: string): Promise<AlterationScript> => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const module = await import(filePath);
|
||||
|
|
|
@ -42,6 +42,11 @@ export const chooseAlterationsByVersion = async (
|
|||
.filter((version, index, self) => index === self.findIndex((another) => eq(version, another)))
|
||||
.slice()
|
||||
.sort((i, j) => compare(j, i));
|
||||
const initialSemVersion = conditional(initialVersion && new SemVer(initialVersion));
|
||||
|
||||
if (!versions[0]) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const { version: targetVersion } =
|
||||
initialVersion === latestTag
|
||||
|
@ -57,14 +62,10 @@ export const chooseAlterationsByVersion = async (
|
|||
})),
|
||||
},
|
||||
{
|
||||
version: conditional(initialVersion && new SemVer(initialVersion)),
|
||||
version: initialSemVersion,
|
||||
}
|
||||
);
|
||||
|
||||
if (!targetVersion) {
|
||||
return [];
|
||||
}
|
||||
|
||||
log.info(`Deploy target ${chalk.green(targetVersion.version)}`);
|
||||
|
||||
return alterations.filter(({ filename }) => {
|
||||
|
|
|
@ -6,7 +6,7 @@ import { hideBin } from 'yargs/helpers';
|
|||
import connector from './commands/connector';
|
||||
import database from './commands/database';
|
||||
import install from './commands/install';
|
||||
import packageJson from './package.json';
|
||||
import { packageJson } from './package-json';
|
||||
import { cliConfig, ConfigKey } from './utilities';
|
||||
|
||||
void yargs(hideBin(process.argv))
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../package.json
|
|
@ -4,7 +4,8 @@
|
|||
"outDir": "lib",
|
||||
"declaration": true,
|
||||
"module": "node16",
|
||||
"target": "es2022"
|
||||
"target": "es2022",
|
||||
"types": ["node", "jest"]
|
||||
},
|
||||
"include": [
|
||||
"src",
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
"@types/koa-mount": "^4.0.0",
|
||||
"@types/koa-send": "^4.1.3",
|
||||
"@types/lodash.pick": "^4.4.6",
|
||||
"@types/node": "^16.3.1",
|
||||
"@types/node": "^16.0.0",
|
||||
"@types/oidc-provider": "^7.11.1",
|
||||
"@types/supertest": "^2.0.11",
|
||||
"copyfiles": "^2.4.1",
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"@silverhand/ts-config": "1.0.0",
|
||||
"@types/jest": "^28.0.0",
|
||||
"@types/lodash.uniq": "^4.5.6",
|
||||
"@types/node": "16",
|
||||
"@types/node": "^16.0.0",
|
||||
"@types/pluralize": "^0.0.29",
|
||||
"camelcase": "^6.2.0",
|
||||
"eslint": "^8.21.0",
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
"@silverhand/jest-config": "1.0.0",
|
||||
"@silverhand/ts-config": "1.0.0",
|
||||
"@types/jest": "^28.1.6",
|
||||
"@types/node": "^16.0.0",
|
||||
"eslint": "^8.21.0",
|
||||
"jest": "^28.1.3",
|
||||
"lint-staged": "^13.0.0",
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
import { lstat } from 'fs/promises';
|
||||
import path from 'path';
|
||||
|
||||
import { conditional } from '@silverhand/essentials';
|
||||
import findUp, { exists } from 'find-up';
|
||||
|
||||
const findPackage = async (cwd: string) =>
|
||||
const findPackage = async (cwd: string, allowSymlink = false) =>
|
||||
findUp(
|
||||
// Will update to 7 soon
|
||||
// eslint-disable-next-line complexity
|
||||
async (directory) => {
|
||||
const hasPackageJson = await exists(path.join(directory, 'package.json'));
|
||||
const testPath = path.join(directory, 'package.json');
|
||||
const hasPackageJson = await exists(testPath);
|
||||
const stat = conditional(hasPackageJson && !allowSymlink && (await lstat(testPath)));
|
||||
|
||||
return conditional(hasPackageJson && directory);
|
||||
return conditional(hasPackageJson && (allowSymlink || !stat?.isSymbolicLink()) && directory);
|
||||
},
|
||||
{
|
||||
cwd,
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
"extends": "@silverhand/ts-config/tsconfig.base",
|
||||
"compilerOptions": {
|
||||
"outDir": "lib",
|
||||
"declaration": true
|
||||
"declaration": true,
|
||||
"types": ["node", "jest"]
|
||||
},
|
||||
"include": [
|
||||
"src",
|
||||
|
|
|
@ -262,7 +262,7 @@ importers:
|
|||
'@types/koa-mount': ^4.0.0
|
||||
'@types/koa-send': ^4.1.3
|
||||
'@types/lodash.pick': ^4.4.6
|
||||
'@types/node': ^16.3.1
|
||||
'@types/node': ^16.0.0
|
||||
'@types/oidc-provider': ^7.11.1
|
||||
'@types/supertest': ^2.0.11
|
||||
chalk: ^4
|
||||
|
@ -571,7 +571,7 @@ importers:
|
|||
'@silverhand/ts-config': 1.0.0
|
||||
'@types/jest': ^28.0.0
|
||||
'@types/lodash.uniq': ^4.5.6
|
||||
'@types/node': '16'
|
||||
'@types/node': ^16.0.0
|
||||
'@types/pluralize': ^0.0.29
|
||||
camelcase: ^6.2.0
|
||||
eslint: ^8.21.0
|
||||
|
@ -619,6 +619,7 @@ importers:
|
|||
'@silverhand/jest-config': 1.0.0
|
||||
'@silverhand/ts-config': 1.0.0
|
||||
'@types/jest': ^28.1.6
|
||||
'@types/node': ^16.0.0
|
||||
dayjs: ^1.10.5
|
||||
eslint: ^8.21.0
|
||||
find-up: ^5.0.0
|
||||
|
@ -640,8 +641,9 @@ importers:
|
|||
'@silverhand/jest-config': 1.0.0_bi2kohzqnxavgozw3csgny5hju
|
||||
'@silverhand/ts-config': 1.0.0_typescript@4.7.4
|
||||
'@types/jest': 28.1.6
|
||||
'@types/node': 16.11.12
|
||||
eslint: 8.21.0
|
||||
jest: 28.1.3
|
||||
jest: 28.1.3_@types+node@16.11.12
|
||||
lint-staged: 13.0.0
|
||||
prettier: 2.7.1
|
||||
typescript: 4.7.4
|
||||
|
@ -4609,7 +4611,7 @@ packages:
|
|||
'@types/http-errors': 1.8.2
|
||||
'@types/keygrip': 1.0.2
|
||||
'@types/koa-compose': 3.2.5
|
||||
'@types/node': 16.11.12
|
||||
'@types/node': 17.0.23
|
||||
dev: true
|
||||
|
||||
/@types/lodash.kebabcase/4.1.6:
|
||||
|
@ -4797,7 +4799,7 @@ packages:
|
|||
resolution: {integrity: sha512-mu/N4uvfDN2zVQQ5AYJI/g4qxn2bHB6521t1UuH09ShNWjebTqN0ZFuYK9uYjcgmI0dTQEs+Owi1EO6U0OkOZQ==}
|
||||
dependencies:
|
||||
'@types/cookiejar': 2.1.2
|
||||
'@types/node': 16.11.12
|
||||
'@types/node': 17.0.23
|
||||
dev: true
|
||||
|
||||
/@types/supertest/2.0.11:
|
||||
|
|
Loading…
Reference in a new issue