0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

Merge pull request #2644 from logto-io/gao-test-native-esm-2

test: use native ESM 2
This commit is contained in:
Gao Sun 2022-12-13 14:58:36 +08:00 committed by GitHub
commit 4619c92dfc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 410 additions and 518 deletions

View file

@ -61,8 +61,8 @@ jobs:
with:
node-version: ${{ matrix.node_version }}
- name: Prepack
run: pnpm prepack
- name: Build for test
run: pnpm -r build:test
- name: Test
run: pnpm ci:test

View file

@ -24,7 +24,7 @@
"@commitlint/config-conventional": "^17.0.0",
"@commitlint/types": "^17.0.0",
"husky": "^8.0.0",
"typescript": "^4.7.4"
"typescript": "^4.9.4"
},
"workspaces": {
"packages": [

View file

@ -1,3 +1,4 @@
/** @type {import('jest').Config} */
const config = {
coveragePathIgnorePatterns: ['/node_modules/', '/src/__mocks__/'],
coverageReporters: ['text-summary', 'lcov'],

View file

@ -25,14 +25,15 @@
"precommit": "lint-staged",
"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",
"build:test": "rm -rf build/ && tsc -p tsconfig.test.json --sourcemap",
"build:test": "rimraf lib/ && pnpm prepare:package-json && tsc -p tsconfig.test.json --sourcemap",
"dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental",
"start": "node .",
"start:dev": "ts-node --files src/index.ts",
"start:dev": "pnpm build && node .",
"lint": "eslint --ext .ts src",
"lint:report": "pnpm lint --format json --output-file report.json",
"test": "pnpm build:test && NODE_OPTIONS=--experimental-vm-modules jest",
"test:ci": "pnpm run test",
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
"test": "pnpm build:test && pnpm test:only",
"test:ci": "pnpm run test:only",
"prepack": "pnpm build"
},
"engines": {
@ -81,7 +82,7 @@
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"sinon": "^15.0.0",
"typescript": "^4.7.4"
"typescript": "^4.9.4"
},
"eslintConfig": {
"extends": "@silverhand",

View file

@ -4,13 +4,12 @@
"outDir": "lib",
"declaration": true,
"moduleResolution": "nodenext",
"module": "es2022",
"module": "esnext",
"target": "es2022",
"types": ["node", "jest"]
},
"include": [
"src",
"jest.*.ts"
"src"
],
"exclude": ["**/alteration-scripts"]
}

View file

@ -87,7 +87,7 @@
"snake-case": "^3.0.4",
"stylelint": "^14.9.1",
"swr": "^1.3.0",
"typescript": "^4.7.4",
"typescript": "^4.9.4",
"zod": "^3.19.1"
},
"engines": {

View file

@ -26,6 +26,8 @@ const RadioGroup = (
return child;
}
// FIXME: @Charles
// @ts-expect-error to be fixed
return cloneElement<RadioProps>(child, {
name,
isChecked: value === child.props.value,

View file

@ -20,8 +20,8 @@
"dev": "rm -rf build/ && pnpm run copyfiles && nodemon",
"start": "NODE_ENV=production node build/index.js",
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
"test": "pnpm build:test && pnpm test:only build/",
"test:ci": "pnpm run test --coverage --silent",
"test": "pnpm build:test && pnpm test:only",
"test:ci": "pnpm run test:only --coverage --silent",
"test:report": "codecov -F core"
},
"dependencies": {
@ -101,7 +101,7 @@
"prettier": "^2.7.1",
"sinon": "^15.0.0",
"supertest": "^6.2.2",
"typescript": "^4.9.3"
"typescript": "^4.9.4"
},
"engines": {
"node": "^16.13.0 || ^18.12.0"

View file

@ -1,6 +1,8 @@
{
"extends": "@silverhand/ts-config/tsconfig.base",
"compilerOptions": {
"moduleResolution": "nodenext",
"module": "esnext",
"declaration": false,
"outDir": "build",
"baseUrl": ".",
@ -8,8 +10,6 @@
"#src/*": [
"src/*"
]
},
"moduleResolution": "nodenext",
"module": "es2022"
}
}
}

View file

@ -8,7 +8,6 @@
]
},
"include": [
"src",
"jest.*.ts"
"src"
]
}

View file

@ -41,7 +41,7 @@
"react-dom": "^18.0.0",
"react-i18next": "^11.18.3",
"stylelint": "^14.9.1",
"typescript": "^4.7.4",
"typescript": "^4.9.4",
"zod": "^3.19.1"
},
"engines": {

View file

@ -0,0 +1,12 @@
/** @type {import('jest').Config} */
const config = {
testPathIgnorePatterns: ['/node_modules/'],
setupFilesAfterEnv: ['./jest.setup.js'],
roots: ['./lib'],
moduleNameMapper: {
'^#src/(.*)\\.js(x)?$': '<rootDir>/lib/$1',
'^(chalk|inquirer)$': '<rootDir>/../shared/lib/esm/module-proxy.js',
},
};
export default config;

View file

@ -1,12 +0,0 @@
import type { Config } from '@silverhand/jest-config';
import { merge } from '@silverhand/jest-config';
const config: Config.InitialOptions = {
...merge({
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
}),
// Will update common config soon
transformIgnorePatterns: ['node_modules/(?!(.*(nanoid|jose|ky|@logto))/)'],
};
export default config;

View file

@ -0,0 +1,10 @@
/** @type {import('jest').Config} */
const config = {
preset: 'jest-puppeteer',
moduleNameMapper: {
'^#src/(.*)\\.js(x)?$': '<rootDir>/lib/$1',
'^(chalk|inquirer)$': '<rootDir>/../shared/lib/esm/module-proxy.js',
},
};
export default config;

View file

@ -1,12 +0,0 @@
import type { Config } from '@silverhand/jest-config';
import { merge } from '@silverhand/jest-config';
const config: Config.InitialOptions = {
// Will treat as CJS
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, unicorn/prefer-module
...merge(require('jest-puppeteer/jest-preset')),
// Will update common config soon
transformIgnorePatterns: ['node_modules/(?!(.*(nanoid|jose|ky|@logto))/)'],
};
export default config;

View file

@ -2,10 +2,10 @@
// https://github.com/jsdom/jsdom/issues/1612
import { Crypto } from '@peculiar/webcrypto';
import dotenv from 'dotenv';
import fetch from 'node-fetch';
import { TextDecoder, TextEncoder } from 'text-encoder';
// eslint-disable-next-line unicorn/prefer-module
const fetch = require('node-fetch');
const { jest } = import.meta;
dotenv.config();

View file

@ -5,11 +5,17 @@
"author": "Silverhand Inc. <contact@silverhand.io>",
"license": "MPL-2.0",
"private": true,
"type": "module",
"imports": {
"#src/*": "./lib/*"
},
"scripts": {
"test": "pnpm test:api && pnpm test:ui",
"test:api": "jest -i ./tests/api",
"test:ui": "jest -i --config=jest.config.ui.ts ./tests/ui",
"lint": "eslint --ext .ts src tests",
"build": "rm -rf lib/ && tsc -p tsconfig.test.json --sourcemap",
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
"test": "pnpm build && pnpm test:api && pnpm test:ui",
"test:api": "pnpm test:only -i ./lib/tests/api",
"test:ui": "pnpm test:only -i --config=jest.config.ui.js ./lib/tests/ui",
"lint": "eslint --ext .ts src",
"lint:report": "pnpm lint --format json --output-file report.json",
"start": "pnpm test"
},
@ -21,14 +27,13 @@
"@peculiar/webcrypto": "^1.3.3",
"@silverhand/eslint-config": "1.3.0",
"@silverhand/essentials": "^1.3.0",
"@silverhand/jest-config": "1.2.2",
"@silverhand/ts-config": "1.2.1",
"@types/jest": "^29.1.2",
"@types/jest-environment-puppeteer": "^5.0.2",
"@types/node": "^16.0.0",
"dotenv": "^16.0.0",
"eslint": "^8.21.0",
"got": "^11.8.5",
"got": "^12.5.3",
"jest": "^29.1.2",
"jest-puppeteer": "^6.1.1",
"node-fetch": "^2.6.7",
@ -37,8 +42,7 @@
"prettier": "^2.7.1",
"puppeteer": "^19.0.0",
"text-encoder": "^0.0.4",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
"typescript": "^4.9.4"
},
"engines": {
"node": "^16.13.0 || ^18.12.0"

View file

@ -1,6 +1,6 @@
import type { User } from '@logto/schemas';
import { authedAdminApi } from './api';
import { authedAdminApi } from './api.js';
type CreateUserPayload = {
primaryEmail?: string;

View file

@ -1,6 +1,6 @@
import got from 'got';
import { got } from 'got';
import { logtoUrl } from '@/constants';
import { logtoUrl } from '#src/constants.js';
export default got.extend({ prefixUrl: new URL('/api', logtoUrl) });

View file

@ -5,7 +5,7 @@ import type {
OidcClientMetadata,
} from '@logto/schemas';
import { authedAdminApi } from './api';
import { authedAdminApi } from './api.js';
export const createApplication = (name: string, type: ApplicationType) =>
authedAdminApi

View file

@ -1,6 +1,6 @@
import type { Connector, ConnectorResponse } from '@logto/schemas';
import { authedAdminApi } from './api';
import { authedAdminApi } from './api.js';
export const listConnectors = async () =>
authedAdminApi.get('connectors').json<ConnectorResponse[]>();

View file

@ -1,4 +1,4 @@
import { authedAdminApi } from './api';
import { authedAdminApi } from './api.js';
export type StatisticsData = {
count: number;

View file

@ -1,12 +1,12 @@
export * from './resource';
export * from './connector';
export * from './application';
export * from './sign-in-experience';
export * from './admin-user';
export * from './session';
export * from './logs';
export * from './dashboard';
export * from './me';
export * from './wellknown';
export * from './resource.js';
export * from './connector.js';
export * from './application.js';
export * from './sign-in-experience.js';
export * from './admin-user.js';
export * from './session.js';
export * from './logs.js';
export * from './dashboard.js';
export * from './me.js';
export * from './wellknown.js';
export { default as api, authedAdminApi } from './api';
export { default as api, authedAdminApi } from './api.js';

View file

@ -1,6 +1,6 @@
import type { Log } from '@logto/schemas';
import { authedAdminApi } from './api';
import { authedAdminApi } from './api.js';
export const getLogs = () => authedAdminApi.get('logs').json<Log[]>();

View file

@ -1,6 +1,6 @@
import type { ArbitraryObject, UserInfo } from '@logto/schemas';
import api from './api';
import api from './api.js';
export const getCurrentUserInfo = (userId: string) =>
api.get(`me`, { headers: { 'development-user-id': userId } }).json<UserInfo>();

View file

@ -1,9 +1,9 @@
import type { Resource, CreateResource } from '@logto/schemas';
import type { OptionsOfTextResponseBody } from 'got';
import { generateResourceIndicator, generateResourceName } from '@/utils';
import { generateResourceIndicator, generateResourceName } from '#src/utils.js';
import { authedAdminApi } from './api';
import { authedAdminApi } from './api.js';
export const createResource = (name?: string, indicator?: string) =>
authedAdminApi

View file

@ -1,6 +1,6 @@
import { PasscodeType } from '@logto/schemas';
import api from './api';
import api from './api.js';
type RedirectResponse = {
redirectTo: string;

View file

@ -1,6 +1,6 @@
import type { SignInExperience } from '@logto/schemas';
import { authedAdminApi } from './api';
import { authedAdminApi } from './api.js';
export const getSignInExperience = () => authedAdminApi.get('sign-in-exp').json<SignInExperience>();

View file

@ -1,6 +1,6 @@
import type { SignInExperience } from '@logto/schemas';
import api from './api';
import api from './api.js';
export const getWellKnownSignInExperience = (interactionCookie: string) =>
api

View file

@ -1,14 +1,14 @@
import type { LogtoConfig } from '@logto/node';
import LogtoClient from '@logto/node';
import { demoAppApplicationId } from '@logto/schemas/lib/seeds';
import { demoAppApplicationId } from '@logto/schemas/lib/seeds/index.js';
import { assert } from '@silverhand/essentials';
import got from 'got';
import { got } from 'got';
import { consent } from '@/api';
import { demoAppRedirectUri, logtoUrl } from '@/constants';
import { extractCookie } from '@/utils';
import { consent } from '#src/api/index.js';
import { demoAppRedirectUri, logtoUrl } from '#src/constants.js';
import { extractCookie } from '#src/utils.js';
import { MemoryStorage } from './storage';
import { MemoryStorage } from './storage.js';
export const defaultConfig = {
endpoint: logtoUrl,

View file

@ -1,8 +1,8 @@
import { SignInIdentifier } from '@logto/schemas';
import { demoAppApplicationId } from '@logto/schemas/lib/seeds';
import { getEnv } from '@silverhand/essentials';
import { assertEnv } from '@silverhand/essentials';
export const logtoUrl = getEnv('INTEGRATION_TESTS_LOGTO_URL');
export const logtoUrl = assertEnv('INTEGRATION_TESTS_LOGTO_URL');
export const discoveryUrl = `${logtoUrl}/oidc/.well-known/openid-configuration`;

View file

@ -13,9 +13,9 @@ import {
getAuthWithSocial,
signInWithSocial,
updateSignInExperience,
} from '@/api';
import MockClient from '@/client';
import { generateUsername, generatePassword } from '@/utils';
} from '#src/api/index.js';
import MockClient from '#src/client/index.js';
import { generateUsername, generatePassword } from '#src/utils.js';
export const createUserByAdmin = (username?: string, password?: string, primaryEmail?: string) => {
return createUser({

View file

@ -0,0 +1,32 @@
/**
* There's an issue for `"moduleResolution": "nodenext"`, thus we need to copy type definitions to here.
* See: https://github.com/microsoft/TypeScript/issues/47848 https://github.com/microsoft/TypeScript/issues/49189
*/
declare module 'openapi-schema-validator' {
import type { ErrorObject } from 'ajv';
import type { IJsonSchema, OpenAPI } from 'openapi-types';
export interface IOpenAPISchemaValidator {
/**
* Validate the provided OpenAPI doc against this validator's schema version and
* return the results.
*/
validate(document: OpenAPI.Document): OpenAPISchemaValidatorResult;
}
export interface OpenAPISchemaValidatorArgs {
version: number | string;
extensions?: IJsonSchema;
}
export interface OpenAPISchemaValidatorResult {
errors: ErrorObject[];
}
class OpenAPISchemaValidator implements IOpenAPISchemaValidator {
private readonly validator;
constructor(args: OpenAPISchemaValidatorArgs);
validate(openapiDocument: OpenAPI.Document): OpenAPISchemaValidatorResult;
}
// eslint-disable-next-line import/no-anonymous-default-export
export default { default: OpenAPISchemaValidator };
}

View file

@ -4,7 +4,7 @@ import {
mockSocialConnectorConfig,
mockSocialConnectorId,
mockSocialConnectorTarget,
} from '@/__mocks__/connectors-mock';
} from '#src/__mocks__/connectors-mock.js';
import {
getUser,
getUsers,
@ -15,8 +15,8 @@ import {
postConnector,
updateConnectorConfig,
deleteConnectorById,
} from '@/api';
import { createUserByAdmin, bindSocialToNewCreatedUser } from '@/helpers';
} from '#src/api/index.js';
import { createUserByAdmin, bindSocialToNewCreatedUser } from '#src/helpers.js';
describe('admin console user management', () => {
it('should create user successfully', async () => {

View file

@ -2,7 +2,12 @@ import { ApplicationType } from '@logto/schemas';
import { demoAppApplicationId } from '@logto/schemas/lib/seeds';
import { HTTPError } from 'got';
import { createApplication, getApplication, updateApplication, deleteApplication } from '@/api';
import {
createApplication,
getApplication,
updateApplication,
deleteApplication,
} from '#src/api/index.js';
describe('admin console application', () => {
it('should get demo app details successfully', async () => {

View file

@ -9,7 +9,7 @@ import {
mockSocialConnectorId,
mockStandardEmailConnectorConfig,
mockStandardEmailConnectorId,
} from '@/__mocks__/connectors-mock';
} from '#src/__mocks__/connectors-mock.js';
import {
deleteConnectorById,
getConnector,
@ -18,7 +18,7 @@ import {
sendEmailTestMessage,
sendSmsTestMessage,
updateConnectorConfig,
} from '@/api/connector';
} from '#src/api/connector.js';
const connectorIdMap = new Map();

View file

@ -1,8 +1,8 @@
import type { StatisticsData } from '@/api';
import { getTotalUsersCount, getNewUsersData, getActiveUsersData } from '@/api';
import { signUpIdentifiers } from '@/constants';
import { createUserByAdmin, registerNewUser, setSignUpIdentifier, signIn } from '@/helpers';
import { generateUsername, generatePassword } from '@/utils';
import type { StatisticsData } from '#src/api/index.js';
import { getTotalUsersCount, getNewUsersData, getActiveUsersData } from '#src/api/index.js';
import { signUpIdentifiers } from '#src/constants.js';
import { createUserByAdmin, registerNewUser, setSignUpIdentifier, signIn } from '#src/helpers.js';
import { generateUsername, generatePassword } from '#src/utils.js';
describe('admin console dashboard', () => {
beforeAll(async () => {

View file

@ -5,11 +5,11 @@ import { managementResource } from '@logto/schemas/lib/seeds';
import { assert } from '@silverhand/essentials';
import fetch from 'node-fetch';
import { signInWithPassword } from '@/api';
import MockClient, { defaultConfig } from '@/client';
import { logtoUrl } from '@/constants';
import { createUserByAdmin } from '@/helpers';
import { generateUsername, generatePassword } from '@/utils';
import { signInWithPassword } from '#src/api/index.js';
import MockClient, { defaultConfig } from '#src/client/index.js';
import { logtoUrl } from '#src/constants.js';
import { createUserByAdmin } from '#src/helpers.js';
import { generateUsername, generatePassword } from '#src/utils.js';
describe('get access token', () => {
const username = generateUsername();

View file

@ -1,4 +1,4 @@
import { api } from '@/api';
import { api } from '#src/api/index.js';
describe('Health check', () => {
it('should have a health state', async () => {

View file

@ -1,9 +1,9 @@
import { assert } from '@silverhand/essentials';
import { getLogs, getLog } from '@/api';
import { signUpIdentifiers } from '@/constants';
import { registerNewUser, setSignUpIdentifier } from '@/helpers';
import { generateUsername, generatePassword } from '@/utils';
import { getLogs, getLog } from '#src/api/index.js';
import { signUpIdentifiers } from '#src/constants.js';
import { registerNewUser, setSignUpIdentifier } from '#src/helpers.js';
import { generateUsername, generatePassword } from '#src/utils.js';
describe('admin console logs', () => {
const username = generateUsername();

View file

@ -1,8 +1,8 @@
import { managementResource } from '@logto/schemas/lib/seeds';
import { HTTPError } from 'got';
import { createResource, getResource, updateResource, deleteResource } from '@/api';
import { generateResourceIndicator, generateResourceName } from '@/utils';
import { createResource, getResource, updateResource, deleteResource } from '#src/api/index.js';
import { generateResourceIndicator, generateResourceName } from '#src/utils.js';
describe('admin console api resources', () => {
it('should get management api resource details successfully', async () => {

View file

@ -7,7 +7,7 @@ import {
mockEmailConnectorConfig,
mockSmsConnectorId,
mockSmsConnectorConfig,
} from '@/__mocks__/connectors-mock';
} from '#src/__mocks__/connectors-mock.js';
import {
sendRegisterUserWithEmailPasscode,
verifyRegisterUserWithEmailPasscode,
@ -23,9 +23,9 @@ import {
deleteConnectorById,
postConnector,
updateConnectorConfig,
} from '@/api';
import MockClient from '@/client';
import { signUpIdentifiers } from '@/constants';
} from '#src/api/index.js';
import MockClient from '#src/client/index.js';
import { signUpIdentifiers } from '#src/constants.js';
import {
registerNewUser,
signIn,
@ -33,8 +33,8 @@ import {
createUserByAdmin,
setSignUpIdentifier,
setSignInMethod,
} from '@/helpers';
import { generateUsername, generatePassword, generateEmail, generatePhone } from '@/utils';
} from '#src/helpers.js';
import { generateUsername, generatePassword, generateEmail, generatePhone } from '#src/utils.js';
const connectorIdMap = new Map();

View file

@ -1,6 +1,6 @@
import { BrandingStyle } from '@logto/schemas';
import { getSignInExperience, updateSignInExperience } from '@/api';
import { getSignInExperience, updateSignInExperience } from '#src/api/index.js';
describe('admin console sign-in experience', () => {
it('should get sign-in experience successfully', async () => {

View file

@ -5,7 +5,7 @@ import {
mockSocialConnectorId,
mockSocialConnectorTarget,
mockSocialConnectorConfig,
} from '@/__mocks__/connectors-mock';
} from '#src/__mocks__/connectors-mock.js';
import {
signInWithSocial,
getAuthWithSocial,
@ -16,11 +16,11 @@ import {
postConnector,
updateConnectorConfig,
deleteConnectorById,
} from '@/api';
import MockClient from '@/client';
import { signUpIdentifiers } from '@/constants';
import { createUserByAdmin, setSignUpIdentifier } from '@/helpers';
import { generateUsername, generatePassword } from '@/utils';
} from '#src/api/index.js';
import MockClient from '#src/client/index.js';
import { signUpIdentifiers } from '#src/constants.js';
import { createUserByAdmin, setSignUpIdentifier } from '#src/helpers.js';
import { generateUsername, generatePassword } from '#src/utils.js';
const state = 'foo_state';
const redirectUri = 'http://foo.dev/callback';

View file

@ -1,7 +1,9 @@
import OpenApiSchemaValidator from 'openapi-schema-validator';
import Validator from 'openapi-schema-validator';
import type { OpenAPI } from 'openapi-types';
import { api } from '@/api';
import { api } from '#src/api/index.js';
const { default: OpenApiSchemaValidator } = Validator;
describe('Swagger check', () => {
it('should provide a valid swagger.json', async () => {

View file

@ -1,9 +1,9 @@
import { adminConsoleApplicationId } from '@logto/schemas/lib/seeds';
import { assert } from '@silverhand/essentials';
import { getWellKnownSignInExperience } from '@/api';
import MockClient from '@/client';
import { adminConsoleRedirectUri } from '@/constants';
import { getWellKnownSignInExperience } from '#src/api/index.js';
import MockClient from '#src/client/index.js';
import { adminConsoleRedirectUri } from '#src/constants.js';
describe('wellknown api', () => {
it('get /.well-known/sign-in-exp for AC', async () => {

View file

@ -1,4 +1,4 @@
import { logtoUrl } from '@/constants';
import { logtoUrl } from '#src/constants.js';
describe('smoke testing', () => {
it('opens with app element', async () => {

View file

@ -1,15 +1,17 @@
{
"extends": "@silverhand/ts-config/tsconfig.base",
"compilerOptions": {
"moduleResolution": "nodenext",
"module": "esnext",
"isolatedModules": false,
"allowJs": true,
"noEmit": true,
"outDir": "lib",
"baseUrl": ".",
"paths": {
"@/*": [
"#src/*": [
"src/*"
]
}
},
"include": ["tests", "src", "jest.*.ts", "jest.setup.js"]
"include": ["src"]
}

View file

@ -23,6 +23,7 @@
"scripts": {
"precommit": "lint-staged",
"build": "rm -rf lib/ && tsc",
"build:test": "pnpm build",
"dev": "tsc --watch --preserveWatchOutput --incremental",
"lint": "eslint --ext .ts src",
"lint:report": "pnpm lint --format json --output-file report.json",
@ -43,7 +44,7 @@
"eslint": "^8.21.0",
"lint-staged": "^13.0.0",
"prettier": "^2.7.1",
"typescript": "^4.7.4"
"typescript": "^4.9.4"
},
"engines": {
"node": "^16.13.0 || ^18.12.0"

View file

@ -4,7 +4,7 @@
"outDir": "lib",
"declaration": true,
"moduleResolution": "nodenext",
"module": "es2022"
"module": "esnext"
},
"include": ["src"]
}

View file

@ -20,6 +20,7 @@
"scripts": {
"precommit": "lint-staged",
"build": "rm -rf lib/ && tsc",
"build:test": "pnpm build",
"dev": "tsc --watch --preserveWatchOutput --incremental",
"lint": "eslint --ext .ts src",
"lint:report": "pnpm lint --format json --output-file report.json",
@ -43,7 +44,7 @@
"eslint": "^8.21.0",
"lint-staged": "^13.0.0",
"prettier": "^2.7.1",
"typescript": "^4.7.4"
"typescript": "^4.9.4"
},
"eslintConfig": {
"extends": "@silverhand"

View file

@ -4,7 +4,7 @@
"outDir": "lib",
"declaration": true,
"moduleResolution": "nodenext",
"module": "es2022"
"module": "esnext"
},
"include": [
"src"

7
packages/schemas/generate.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
rm -rf lib/
pnpm exec tsc -p tsconfig.build.gen.json
rm -rf src/db-entries
node lib/index.js
pnpm exec eslint src/db-entries/** --fix

View file

@ -0,0 +1,11 @@
/** @type {import('jest').Config} */
const config = {
coveragePathIgnorePatterns: ['/node_modules/', '/src/__mocks__/'],
coverageReporters: ['text-summary', 'lcov'],
roots: ['./lib'],
moduleNameMapper: {
'^(chalk|inquirer)$': '<rootDir>/../shared/lib/esm/module-proxy.js',
},
};
export default config;

View file

@ -1,16 +0,0 @@
import type { Config } from '@silverhand/jest-config';
import { merge } from '@silverhand/jest-config';
const config: Config.InitialOptions = {
...merge({
// Will update common config soon
transformIgnorePatterns: ['node_modules/(?!(.*(nanoid|jose|ky|@logto))/)'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
}),
// Will update common config soon
transformIgnorePatterns: ['node_modules/(?!(.*(nanoid|jose|ky|@logto))/)'],
};
export default config;

View file

@ -17,15 +17,17 @@
"scripts": {
"precommit": "lint-staged",
"version": "./update-next.sh && git add alterations/",
"generate": "rm -rf src/db-entries && ts-node-esm src/gen/index.ts && eslint \"src/db-entries/**\" --fix",
"generate": "./generate.sh",
"build:alterations": "rm -rf alterations-js && tsc -p tsconfig.build.alterations.json",
"build": "pnpm generate && rm -rf lib/ && tsc -p tsconfig.build.json && pnpm build:alterations",
"build:test": "pnpm generate && rm -rf lib/ && tsc -p tsconfig.test.json --sourcemap",
"dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental",
"lint": "eslint --ext .ts src",
"lint:report": "pnpm lint --format json --output-file report.json",
"prepack": "pnpm build",
"test": "jest",
"test:ci": "jest"
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
"test": "pnpm build:test && pnpm test:only",
"test:ci": "pnpm run test:only"
},
"engines": {
"node": "^16.13.0 || ^18.12.0"
@ -33,7 +35,6 @@
"devDependencies": {
"@silverhand/eslint-config": "1.3.0",
"@silverhand/essentials": "^1.3.0",
"@silverhand/jest-config": "1.2.2",
"@silverhand/ts-config": "1.2.1",
"@types/jest": "^29.1.2",
"@types/lodash.uniq": "^4.5.6",
@ -47,8 +48,7 @@
"pluralize": "^8.0.0",
"prettier": "^2.7.1",
"slonik": "^30.0.0",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
"typescript": "^4.9.4"
},
"eslintConfig": {
"extends": "@silverhand",

View file

@ -0,0 +1,4 @@
{
"extends": "./tsconfig",
"include": ["src/gen"]
}

View file

@ -4,11 +4,10 @@
"outDir": "lib",
"declaration": true,
"moduleResolution": "nodenext",
"module": "es2022"
"module": "esnext"
},
"include": [
"src",
"alterations",
"jest.config.ts"
"alterations"
]
}

View file

@ -1,3 +1,8 @@
{
"extends": "./tsconfig"
"extends": "./tsconfig",
"compilerOptions": {
"isolatedModules": false,
"allowJs": true
},
"include": ["src"]
}

View file

@ -0,0 +1,11 @@
/** @type {import('jest').Config} */
const config = {
coveragePathIgnorePatterns: ['/node_modules/', '/src/__mocks__/'],
coverageReporters: ['text-summary', 'lcov'],
roots: ['./lib'],
moduleNameMapper: {
'^(chalk|inquirer)$': '<rootDir>/../shared/lib/esm/module-proxy.js',
},
};
export default config;

View file

@ -1,15 +0,0 @@
import type { Config } from '@silverhand/jest-config';
import { merge } from '@silverhand/jest-config';
const config: Config.InitialOptions = {
...merge({
roots: ['./src'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
}),
// Will update common config soon
transformIgnorePatterns: ['node_modules/(?!(.*(nanoid|jose|ky|@logto))/)'],
};
export default config;

View file

@ -22,16 +22,17 @@
"scripts": {
"precommit": "lint-staged",
"build": "rm -rf lib/ && tsc -p tsconfig.build.json",
"build:test": "rm -rf lib/ && tsc -p tsconfig.test.json --sourcemap",
"dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental",
"lint": "eslint --ext .ts src",
"lint:report": "pnpm lint --format json --output-file report.json",
"prepack": "pnpm build",
"test": "jest",
"test:ci": "jest"
"test:only": "NODE_OPTIONS=--experimental-vm-modules jest",
"test": "pnpm build:test && pnpm test:only",
"test:ci": "pnpm run test:only"
},
"devDependencies": {
"@silverhand/eslint-config": "1.3.0",
"@silverhand/jest-config": "1.2.2",
"@silverhand/ts-config": "1.2.1",
"@types/jest": "^29.1.2",
"@types/node": "^16.0.0",
@ -39,7 +40,7 @@
"jest": "^29.1.2",
"lint-staged": "^13.0.0",
"prettier": "^2.7.1",
"typescript": "^4.7.4"
"typescript": "^4.9.4"
},
"engines": {
"node": "^16.13.0 || ^18.12.0"

View file

@ -11,6 +11,8 @@ import {
conditionalSql,
} from './utils.js';
const { jest } = import.meta;
describe('conditionalSql()', () => {
it('returns empty sql when value is falsy', () => {
expect(conditionalSql(false, () => sql`select 1`)).toEqual({

View file

@ -5,10 +5,9 @@
"declaration": true,
"types": ["node", "jest"],
"moduleResolution": "nodenext",
"module": "es2022"
"module": "esnext"
},
"include": [
"src",
"jest.config.ts"
"src"
]
}

View file

@ -67,7 +67,7 @@
"react-timer-hook": "^3.0.5",
"stylelint": "^14.9.1",
"superstruct": "^0.16.0",
"typescript": "^4.7.4",
"typescript": "^4.9.4",
"use-debounced-loader": "^0.1.1",
"zod": "^3.19.1"
},

File diff suppressed because it is too large Load diff