mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
Use essentials
This commit is contained in:
parent
163ca3e51f
commit
053b775e49
9 changed files with 36 additions and 45 deletions
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"printWidth": 100,
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": true
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"space": true,
|
||||
"prettier": true,
|
||||
"rules": {
|
||||
"unicorn/no-array-reduce": "off"
|
||||
}
|
||||
}
|
|
@ -5,18 +5,20 @@
|
|||
"repository": "https://github.com/logto-io/schemas",
|
||||
"author": "Logto",
|
||||
"license": "UNLICENSED",
|
||||
"files": ["lib"],
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"generate": "ts-node src/gen/index.ts",
|
||||
"build": "yarn generate && rm -rf lib/ && tsc --p tsconfig.build.json",
|
||||
"lint": "xo src/",
|
||||
"prepare": "yarn build"
|
||||
"lint": "xo src/"
|
||||
},
|
||||
"engines": {
|
||||
"node": "14",
|
||||
"yarn": "1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@logto/essentials": "^1.0.2",
|
||||
"@types/node": "14",
|
||||
"@types/pluralize": "^0.0.29",
|
||||
"camelcase": "^6.2.0",
|
||||
|
@ -24,5 +26,6 @@
|
|||
"ts-node": "^10.0.0",
|
||||
"typescript": "^4.3.4",
|
||||
"xo": "0.39.1"
|
||||
}
|
||||
},
|
||||
"prettier": "@logto/essentials/.prettierrc.json"
|
||||
}
|
||||
|
|
|
@ -3,14 +3,9 @@ import camelcase from 'camelcase';
|
|||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
import pluralize from 'pluralize';
|
||||
import { conditionalString } from '@logto/essentials';
|
||||
|
||||
import {
|
||||
conditionalString,
|
||||
findFirstParentheses,
|
||||
getType,
|
||||
normalizeWhitespaces,
|
||||
removeParentheses,
|
||||
} from './utils';
|
||||
import { findFirstParentheses, getType, normalizeWhitespaces, removeParentheses } from './utils';
|
||||
|
||||
type Field = {
|
||||
name: string;
|
||||
|
@ -98,10 +93,10 @@ const generate = async () => {
|
|||
'',
|
||||
`export const ${camelcase(name, { pascalCase: true })} = Object.freeze({`,
|
||||
` table: '${name}',`,
|
||||
` fields: {`,
|
||||
' fields: {',
|
||||
...fields.map(({ name }) => ` ${camelcase(name)}: '${name}',`),
|
||||
` },`,
|
||||
`} as const);`,
|
||||
' },',
|
||||
'} as const);',
|
||||
].join('\n')
|
||||
)
|
||||
.join('\n') +
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
import { Optional } from '../global';
|
||||
|
||||
export type Falsy = 0 | undefined | null | false | '';
|
||||
|
||||
export const conditionalString = (value: string | Falsy): string => (value ? value : '');
|
||||
import { Optional } from '@logto/essentials';
|
||||
|
||||
export const normalizeWhitespaces = (string: string): string => string.replace(/\s+/g, ' ').trim();
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export type Optional<T> = T | undefined;
|
|
@ -1,17 +1,8 @@
|
|||
{
|
||||
"extends": "@logto/essentials/tsconfig.base",
|
||||
"compilerOptions": {
|
||||
"target": "es2021",
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"declaration": true,
|
||||
"outDir": "lib"
|
||||
"outDir": "lib",
|
||||
"declaration": true
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
"include": ["src"]
|
||||
}
|
||||
|
|
1
packages/schemas/xo.config.js
Normal file
1
packages/schemas/xo.config.js
Normal file
|
@ -0,0 +1 @@
|
|||
module.exports = require("@logto/essentials/.xo-config.json");
|
|
@ -232,6 +232,14 @@
|
|||
minimatch "^3.0.4"
|
||||
strip-json-comments "^3.1.1"
|
||||
|
||||
"@logto/essentials@^1.0.2":
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@logto/essentials/-/essentials-1.0.2.tgz#02a8c878b4079a63709c35ce8c143370f259bb13"
|
||||
integrity sha512-GN6m1c5ll7EhOgJbmFwRESkeWGjdoihst8O1aVIxvEOXhLe/79bph4hejsdm59piX3jgKWakEHimpqcBT1kO+Q==
|
||||
dependencies:
|
||||
lodash.orderby "^4.6.0"
|
||||
lodash.pick "^4.4.0"
|
||||
|
||||
"@mrmlnc/readdir-enhanced@^2.2.1":
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"
|
||||
|
@ -2534,6 +2542,16 @@ lodash.merge@^4.6.2:
|
|||
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
|
||||
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
|
||||
|
||||
lodash.orderby@^4.6.0:
|
||||
version "4.6.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.orderby/-/lodash.orderby-4.6.0.tgz#e697f04ce5d78522f54d9338b32b81a3393e4eb3"
|
||||
integrity sha1-5pfwTOXXhSL1TZM4syuBozk+TrM=
|
||||
|
||||
lodash.pick@^4.4.0:
|
||||
version "4.4.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3"
|
||||
integrity sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM=
|
||||
|
||||
lodash.truncate@^4.4.2:
|
||||
version "4.4.2"
|
||||
resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193"
|
||||
|
|
Loading…
Reference in a new issue