Skip to content

chore: replace some unused/small/deprecated/long-updated dependencies and remove some spaces #2144

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

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@
"eslint": "^8.57.0",
"eslint-plugin-jest": "^28.2.0",
"jest": "^29.7.0",
"replace-in-file": "^7.0.1",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsup": "^8.0.1",
"tsx": "^4.7.1",
"typescript": "^5.4.4"
Expand Down
4 changes: 2 additions & 2 deletions packages/ide/jetbrains/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ changelog {
introduction.set(
"""
[ZenStack](https://zenstack.dev) is a toolkit that simplifies the development of a web app's backend. This plugin provides code editing experiences for its ZModel schema language.

## Features

- Syntax highlighting
- Error highlighting
- Go to definition
Expand Down
6 changes: 3 additions & 3 deletions packages/language/src/zmodel.langium
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Argument:
DataModel:
(comments+=TRIPLE_SLASH_COMMENT)*
(
((isAbstract?='abstract')? 'model' name=RegularID
((isAbstract?='abstract')? 'model' name=RegularID
('extends' superTypes+=[DataModel] (',' superTypes+=[DataModel])*)?) |
((isView?='view') name=RegularID)
)
Expand Down Expand Up @@ -193,7 +193,7 @@ TypeDef:
type TypeDefFieldTypes = TypeDef | Enum;

TypeDefField:
(comments+=TRIPLE_SLASH_COMMENT)*
(comments+=TRIPLE_SLASH_COMMENT)*
name=RegularIDWithTypeNames type=TypeDefFieldType (attributes+=DataModelFieldAttribute)*;

TypeDefFieldType:
Expand All @@ -208,7 +208,7 @@ Enum:
'enum' name=RegularID '{' (
fields+=EnumField
| attributes+=DataModelAttribute
)+
)+
'}';

EnumField:
Expand Down
6 changes: 1 addition & 5 deletions packages/plugins/openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@
"dependencies": {
"@zenstackhq/runtime": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"change-case": "^4.1.2",
"lower-case-first": "^2.0.2",
"openapi-types": "^12.1.0",
"semver": "^7.5.2",
"tiny-invariant": "^1.3.1",
"ts-pattern": "^4.3.0",
"upper-case-first": "^2.0.2",
"yaml": "^2.2.2",
"zod": "^3.22.4",
"zod": "^3.22.4",
"zod-validation-error": "^1.5.0"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/openapi/src/rest-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ import {
TypeDefFieldType,
} from '@zenstackhq/sdk/ast';
import type { DMMF } from '@zenstackhq/sdk/prisma';
import { invariant, lowerCaseFirst } from '@zenstackhq/runtime/local-helpers';
import fs from 'fs';
import { lowerCaseFirst } from 'lower-case-first';
import type { OpenAPIV3_1 as OAPI } from 'openapi-types';
import path from 'path';
import pluralize from 'pluralize';
import invariant from 'tiny-invariant';
import { match, P } from 'ts-pattern';
import YAML from 'yaml';
import { name } from '.';
Expand Down
4 changes: 1 addition & 3 deletions packages/plugins/openapi/src/rpc-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ import {
resolveAggregateOperationSupport,
} from '@zenstackhq/sdk/dmmf-helpers';
import { supportCreateMany, type DMMF } from '@zenstackhq/sdk/prisma';
import { lowerCaseFirst, upperCaseFirst, invariant } from '@zenstackhq/runtime/local-helpers';
import * as fs from 'fs';
import { lowerCaseFirst } from 'lower-case-first';
import type { OpenAPIV3_1 as OAPI } from 'openapi-types';
import * as path from 'path';
import invariant from 'tiny-invariant';
import { P, match } from 'ts-pattern';
import { upperCaseFirst } from 'upper-case-first';
import YAML from 'yaml';
import { name } from '.';
import { OpenAPIGeneratorBase } from './generator-base';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tags:
- name: post_Item
description: Post-related operations
- name: postLike
description: PostLike operations
description: PostLike operations
paths:
/user:
get:
Expand Down
5 changes: 1 addition & 4 deletions packages/plugins/swr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,10 @@
"dependencies": {
"@zenstackhq/runtime": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"change-case": "^4.1.2",
"cross-fetch": "^4.0.0",
"lower-case-first": "^2.0.2",
"semver": "^7.5.2",
"ts-morph": "^16.0.0",
"ts-pattern": "^4.3.0",
"upper-case-first": "^2.0.2"
"ts-pattern": "^4.3.0"
},
"peerDependencies": {
"swr": "2.2.5 - 2"
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/swr/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import {
} from '@zenstackhq/sdk';
import { DataModel, DataModelFieldType, Model, isEnum, isTypeDef } from '@zenstackhq/sdk/ast';
import { getPrismaClientImportSpec, supportCreateMany, type DMMF } from '@zenstackhq/sdk/prisma';
import { paramCase } from 'change-case';
import { upperCaseFirst, paramCase } from '@zenstackhq/runtime/local-helpers';
import path from 'path';
import type { OptionalKind, ParameterDeclarationStructure, Project, SourceFile } from 'ts-morph';
import { P, match } from 'ts-pattern';
import { upperCaseFirst } from 'upper-case-first';
import { name } from '.';

export async function generate(model: Model, options: PluginOptions, dmmf: DMMF.Document) {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/swr/src/runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type ModelMeta,
type PrismaWriteActionType,
} from '@zenstackhq/runtime/cross';
import { lowerCaseFirst } from 'lower-case-first';
import { lowerCaseFirst } from '@zenstackhq/runtime/local-helpers';
import { createContext, useContext } from 'react';
import type { Cache, Fetcher, SWRConfiguration, SWRResponse } from 'swr';
import useSWR, { useSWRConfig } from 'swr';
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/swr/tests/react-hooks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/// <reference types="@types/jest" />

import { renderHook, waitFor } from '@testing-library/react';
import { lowerCaseFirst } from 'lower-case-first';
import { lowerCaseFirst } from '@zenstackhq/runtime/local-helpers';
import nock from 'nock';
import { SWRConfig, useSWRConfig } from 'swr';
import {
Expand Down
7 changes: 2 additions & 5 deletions packages/plugins/tanstack-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,10 @@
"dependencies": {
"@zenstackhq/runtime": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"change-case": "^4.1.2",
"cross-fetch": "^4.0.0",
"lower-case-first": "^2.0.2",
"semver": "^7.5.2",
"ts-morph": "^16.0.0",
"ts-pattern": "^4.3.0",
"upper-case-first": "^2.0.2"
"ts-pattern": "^4.3.0"
},
"devDependencies": {
"@tanstack/react-query": "^4.29.7",
Expand All @@ -101,11 +98,11 @@
"@types/semver": "^7.3.13",
"@types/tmp": "^0.2.3",
"@zenstackhq/testtools": "workspace:*",
"glob": "^8.1.0",
"jest-environment-jsdom": "^29.7.0",
"nock": "^13.3.6",
"react": "18.2.0",
"react-test-renderer": "^18.2.0",
"replace-in-file": "^7.0.1",
"svelte": "^4.2.1",
"swr": "^2.0.3",
"tmp": "^0.2.3",
Expand Down
33 changes: 24 additions & 9 deletions packages/plugins/tanstack-query/scripts/postbuild.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
// tsup doesn't replace npm dependency aliases in the dist files, so we have to do it manually

const replace = require('replace-in-file');
const fs = require('fs');
const glob = require('glob');

function replaceSync({ file, from, to }) {
const paths = glob.sync(file, { ignore: [], nodir: true });

paths.forEach(path => {
const contents = fs.readFileSync(path, { encoding: 'utf-8' });

const newContents = contents.replace(from, to);

if (newContents !== contents) {
fs.writeFileSync(path, newContents, { encoding: 'utf-8' });
}
});
}

// tsup incorrectly resolve to legacy types, make a fix here
console.log('Replacing @tanstack/react-query-v5/build/legacy/types');
replace.sync({
files: 'dist/runtime-v5/react*(.d.ts|.d.mts)',
replaceSync({
file: 'dist/runtime-v5/react*(.d.ts|.d.mts)',
from: /@tanstack\/react-query-v5\/build\/legacy\/types/g,
to: '@tanstack/react-query',
});

console.log('Replacing @tanstack/react-query-v5');
replace.sync({
files: 'dist/runtime-v5/react*(.d.ts|.d.mts|.js|.mjs)',
replaceSync({
file: 'dist/runtime-v5/react*(.d.ts|.d.mts|.js|.mjs)',
from: /@tanstack\/react-query-v5/g,
to: '@tanstack/react-query',
});

console.log('Replacing @tanstack/svelte-query-v5');
replace.sync({
files: 'dist/runtime-v5/svelte*(.d.ts|.d.mts|.js|.mjs)',
replaceSync({
file: 'dist/runtime-v5/svelte*(.d.ts|.d.mts|.js|.mjs)',
from: /@tanstack\/svelte-query-v5/g,
to: '@tanstack/svelte-query',
});

console.log('Replacing @tanstack/vue-query-v5');
replace.sync({
files: 'dist/runtime-v5/vue*(.d.ts|.d.mts|.js|.mjs)',
replaceSync({
file: 'dist/runtime-v5/vue*(.d.ts|.d.mts|.js|.mjs)',
from: /@tanstack\/vue-query-v5/g,
to: '@tanstack/vue-query',
});
4 changes: 1 addition & 3 deletions packages/plugins/tanstack-query/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ import {
} from '@zenstackhq/sdk';
import { DataModel, DataModelFieldType, Model, isEnum, isTypeDef } from '@zenstackhq/sdk/ast';
import { getPrismaClientImportSpec, supportCreateMany, type DMMF } from '@zenstackhq/sdk/prisma';
import { paramCase } from 'change-case';
import { lowerCaseFirst, upperCaseFirst, paramCase } from '@zenstackhq/runtime/local-helpers';
import fs from 'fs';
import { lowerCaseFirst } from 'lower-case-first';
import path from 'path';
import { Project, SourceFile, VariableDeclarationKind } from 'ts-morph';
import { P, match } from 'ts-pattern';
import { upperCaseFirst } from 'upper-case-first';
import { name } from '.';

const supportedTargets = ['react', 'vue', 'svelte'];
Expand Down
8 changes: 3 additions & 5 deletions packages/plugins/trpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@
"author": "ZenStack Team",
"license": "MIT",
"dependencies": {
"@zenstackhq/runtime": "workspace:*",
"@zenstackhq/sdk": "workspace:*",
"change-case": "^4.1.2",
"lower-case-first": "^2.0.2",
"ts-morph": "^16.0.0",
"tslib": "^2.4.1",
"upper-case-first": "^2.0.2"
"tslib": "^2.4.1"
},
"peerDependencies": {
"zod": "^3.22.4"
"zod": "^3.22.4"
},
"devDependencies": {
"@trpc/next": "^10.32.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/trpc/src/client-helper/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PluginError, type PluginOptions } from '@zenstackhq/sdk';
import { getPrismaClientImportSpec } from '@zenstackhq/sdk/prisma';
import { lowerCaseFirst, upperCaseFirst } from '@zenstackhq/runtime/local-helpers';
import fs from 'fs';
import { lowerCaseFirst } from 'lower-case-first';
import path from 'path';
import {
InterfaceDeclarationStructure,
Expand All @@ -10,7 +10,6 @@ import {
SourceFile,
StructureKind,
} from 'ts-morph';
import { upperCaseFirst } from 'upper-case-first';
import { name } from '..';
import { SupportedClientHelpers } from '../utils';
import * as NextHelpers from './next';
Expand Down
7 changes: 3 additions & 4 deletions packages/plugins/trpc/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import {
} from '@zenstackhq/sdk';
import { DataModel, isDataModel, Model } from '@zenstackhq/sdk/ast';
import { getPrismaClientImportSpec, supportCreateMany, type DMMF } from '@zenstackhq/sdk/prisma';
import { lowerCaseFirst } from 'lower-case-first';
import { lowerCaseFirst, upperCaseFirst } from '@zenstackhq/runtime/local-helpers';
import path from 'path';
import { Project } from 'ts-morph';
import { upperCaseFirst } from 'upper-case-first';
import { name } from '.';
import { createClientHelperEntries, generateClientTypingForModel } from './client-helper';
import { project } from './project';
Expand Down Expand Up @@ -169,12 +168,12 @@ function createAppRouter(
>(
procedures: ProcRouterRecord
) => CreateRouterInner<Config, ProcRouterRecord>;

export type UnsetMarker = typeof unsetMarker;

export type ProcBuilder<Config extends BaseConfig> = ProcedureBuilder<
ProcedureParams<Config, any, any, any, UnsetMarker, UnsetMarker, any>
>;
>;
`);
} else {
appRouter.addImportDeclaration({
Expand Down
3 changes: 1 addition & 2 deletions packages/plugins/trpc/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { type DMMF } from '@zenstackhq/sdk/prisma';
import { lowerCaseFirst } from 'lower-case-first';
import { lowerCaseFirst, upperCaseFirst } from '@zenstackhq/runtime/local-helpers';
import { CodeBlockWriter, SourceFile } from 'ts-morph';
import { upperCaseFirst } from 'upper-case-first';

/**
* Supported client helper types
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"trpc-nuxt": "^0.10.22",
"vue": "latest",
"vue-router": "latest",
"zod": "^3.22.4"
"zod": "^3.22.4"
},
"devDependencies": {
"esbuild": "^0.24.0",
Expand Down
Loading
Loading