Skip to content

Commit 6e147e9

Browse files
DoctorFTBymc9
andauthored
chore: replace some unused/small/deprecated/long-updated dependencies and remove some spaces (#2144)
Co-authored-by: Yiming Cao <[email protected]>
1 parent 8ab7564 commit 6e147e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+222
-469
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@
3434
"eslint": "^8.57.0",
3535
"eslint-plugin-jest": "^28.2.0",
3636
"jest": "^29.7.0",
37-
"replace-in-file": "^7.0.1",
3837
"rimraf": "^3.0.2",
3938
"ts-jest": "^29.1.1",
40-
"ts-node": "^10.9.1",
4139
"tsup": "^8.0.1",
4240
"tsx": "^4.7.1",
4341
"typescript": "^5.4.4"

packages/ide/jetbrains/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ changelog {
8585
introduction.set(
8686
"""
8787
[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.
88-
88+
8989
## Features
90-
90+
9191
- Syntax highlighting
9292
- Error highlighting
9393
- Go to definition

packages/language/src/zmodel.langium

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Argument:
164164
DataModel:
165165
(comments+=TRIPLE_SLASH_COMMENT)*
166166
(
167-
((isAbstract?='abstract')? 'model' name=RegularID
167+
((isAbstract?='abstract')? 'model' name=RegularID
168168
('extends' superTypes+=[DataModel] (',' superTypes+=[DataModel])*)?) |
169169
((isView?='view') name=RegularID)
170170
)
@@ -193,7 +193,7 @@ TypeDef:
193193
type TypeDefFieldTypes = TypeDef | Enum;
194194

195195
TypeDefField:
196-
(comments+=TRIPLE_SLASH_COMMENT)*
196+
(comments+=TRIPLE_SLASH_COMMENT)*
197197
name=RegularIDWithTypeNames type=TypeDefFieldType (attributes+=DataModelFieldAttribute)*;
198198

199199
TypeDefFieldType:
@@ -208,7 +208,7 @@ Enum:
208208
'enum' name=RegularID '{' (
209209
fields+=EnumField
210210
| attributes+=DataModelAttribute
211-
)+
211+
)+
212212
'}';
213213

214214
EnumField:

packages/plugins/openapi/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,11 @@
2828
"dependencies": {
2929
"@zenstackhq/runtime": "workspace:*",
3030
"@zenstackhq/sdk": "workspace:*",
31-
"change-case": "^4.1.2",
32-
"lower-case-first": "^2.0.2",
3331
"openapi-types": "^12.1.0",
3432
"semver": "^7.5.2",
35-
"tiny-invariant": "^1.3.1",
3633
"ts-pattern": "^4.3.0",
37-
"upper-case-first": "^2.0.2",
3834
"yaml": "^2.2.2",
39-
"zod": "^3.22.4",
35+
"zod": "^3.22.4",
4036
"zod-validation-error": "^1.5.0"
4137
},
4238
"devDependencies": {

packages/plugins/openapi/src/rest-generator.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ import {
2626
TypeDefFieldType,
2727
} from '@zenstackhq/sdk/ast';
2828
import type { DMMF } from '@zenstackhq/sdk/prisma';
29+
import { invariant, lowerCaseFirst } from '@zenstackhq/runtime/local-helpers';
2930
import fs from 'fs';
30-
import { lowerCaseFirst } from 'lower-case-first';
3131
import type { OpenAPIV3_1 as OAPI } from 'openapi-types';
3232
import path from 'path';
3333
import pluralize from 'pluralize';
34-
import invariant from 'tiny-invariant';
3534
import { match, P } from 'ts-pattern';
3635
import YAML from 'yaml';
3736
import { name } from '.';

packages/plugins/openapi/src/rpc-generator.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ import {
1111
resolveAggregateOperationSupport,
1212
} from '@zenstackhq/sdk/dmmf-helpers';
1313
import { supportCreateMany, type DMMF } from '@zenstackhq/sdk/prisma';
14+
import { lowerCaseFirst, upperCaseFirst, invariant } from '@zenstackhq/runtime/local-helpers';
1415
import * as fs from 'fs';
15-
import { lowerCaseFirst } from 'lower-case-first';
1616
import type { OpenAPIV3_1 as OAPI } from 'openapi-types';
1717
import * as path from 'path';
18-
import invariant from 'tiny-invariant';
1918
import { P, match } from 'ts-pattern';
20-
import { upperCaseFirst } from 'upper-case-first';
2119
import YAML from 'yaml';
2220
import { name } from '.';
2321
import { OpenAPIGeneratorBase } from './generator-base';

packages/plugins/openapi/tests/baseline/rest-3.1.0.baseline.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ tags:
1010
- name: post_Item
1111
description: Post-related operations
1212
- name: postLike
13-
description: PostLike operations
13+
description: PostLike operations
1414
paths:
1515
/user:
1616
get:

packages/plugins/swr/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,10 @@
4040
"dependencies": {
4141
"@zenstackhq/runtime": "workspace:*",
4242
"@zenstackhq/sdk": "workspace:*",
43-
"change-case": "^4.1.2",
4443
"cross-fetch": "^4.0.0",
45-
"lower-case-first": "^2.0.2",
4644
"semver": "^7.5.2",
4745
"ts-morph": "^16.0.0",
48-
"ts-pattern": "^4.3.0",
49-
"upper-case-first": "^2.0.2"
46+
"ts-pattern": "^4.3.0"
5047
},
5148
"peerDependencies": {
5249
"swr": "2.2.5 - 2"

packages/plugins/swr/src/generator.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ import {
1212
} from '@zenstackhq/sdk';
1313
import { DataModel, DataModelFieldType, Model, isEnum, isTypeDef } from '@zenstackhq/sdk/ast';
1414
import { getPrismaClientImportSpec, supportCreateMany, type DMMF } from '@zenstackhq/sdk/prisma';
15-
import { paramCase } from 'change-case';
15+
import { upperCaseFirst, paramCase } from '@zenstackhq/runtime/local-helpers';
1616
import path from 'path';
1717
import type { OptionalKind, ParameterDeclarationStructure, Project, SourceFile } from 'ts-morph';
1818
import { P, match } from 'ts-pattern';
19-
import { upperCaseFirst } from 'upper-case-first';
2019
import { name } from '.';
2120

2221
export async function generate(model: Model, options: PluginOptions, dmmf: DMMF.Document) {

packages/plugins/swr/src/runtime/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
type ModelMeta,
88
type PrismaWriteActionType,
99
} from '@zenstackhq/runtime/cross';
10-
import { lowerCaseFirst } from 'lower-case-first';
10+
import { lowerCaseFirst } from '@zenstackhq/runtime/local-helpers';
1111
import { createContext, useContext } from 'react';
1212
import type { Cache, Fetcher, SWRConfiguration, SWRResponse } from 'swr';
1313
import useSWR, { useSWRConfig } from 'swr';

packages/plugins/swr/tests/react-hooks.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/// <reference types="@types/jest" />
88

99
import { renderHook, waitFor } from '@testing-library/react';
10-
import { lowerCaseFirst } from 'lower-case-first';
10+
import { lowerCaseFirst } from '@zenstackhq/runtime/local-helpers';
1111
import nock from 'nock';
1212
import { SWRConfig, useSWRConfig } from 'swr';
1313
import {

packages/plugins/tanstack-query/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,10 @@
8282
"dependencies": {
8383
"@zenstackhq/runtime": "workspace:*",
8484
"@zenstackhq/sdk": "workspace:*",
85-
"change-case": "^4.1.2",
8685
"cross-fetch": "^4.0.0",
87-
"lower-case-first": "^2.0.2",
8886
"semver": "^7.5.2",
8987
"ts-morph": "^16.0.0",
90-
"ts-pattern": "^4.3.0",
91-
"upper-case-first": "^2.0.2"
88+
"ts-pattern": "^4.3.0"
9289
},
9390
"devDependencies": {
9491
"@tanstack/react-query": "^4.29.7",
@@ -101,11 +98,11 @@
10198
"@types/semver": "^7.3.13",
10299
"@types/tmp": "^0.2.3",
103100
"@zenstackhq/testtools": "workspace:*",
101+
"glob": "^8.1.0",
104102
"jest-environment-jsdom": "^29.7.0",
105103
"nock": "^13.3.6",
106104
"react": "18.2.0",
107105
"react-test-renderer": "^18.2.0",
108-
"replace-in-file": "^7.0.1",
109106
"svelte": "^4.2.1",
110107
"swr": "^2.0.3",
111108
"tmp": "^0.2.3",
Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,47 @@
11
// tsup doesn't replace npm dependency aliases in the dist files, so we have to do it manually
22

3-
const replace = require('replace-in-file');
3+
const fs = require('fs');
4+
const glob = require('glob');
5+
6+
function replaceSync({ file, from, to }) {
7+
const paths = glob.sync(file, { ignore: [], nodir: true });
8+
9+
paths.forEach(path => {
10+
const contents = fs.readFileSync(path, { encoding: 'utf-8' });
11+
12+
const newContents = contents.replace(from, to);
13+
14+
if (newContents !== contents) {
15+
fs.writeFileSync(path, newContents, { encoding: 'utf-8' });
16+
}
17+
});
18+
}
419

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

1328
console.log('Replacing @tanstack/react-query-v5');
14-
replace.sync({
15-
files: 'dist/runtime-v5/react*(.d.ts|.d.mts|.js|.mjs)',
29+
replaceSync({
30+
file: 'dist/runtime-v5/react*(.d.ts|.d.mts|.js|.mjs)',
1631
from: /@tanstack\/react-query-v5/g,
1732
to: '@tanstack/react-query',
1833
});
1934

2035
console.log('Replacing @tanstack/svelte-query-v5');
21-
replace.sync({
22-
files: 'dist/runtime-v5/svelte*(.d.ts|.d.mts|.js|.mjs)',
36+
replaceSync({
37+
file: 'dist/runtime-v5/svelte*(.d.ts|.d.mts|.js|.mjs)',
2338
from: /@tanstack\/svelte-query-v5/g,
2439
to: '@tanstack/svelte-query',
2540
});
2641

2742
console.log('Replacing @tanstack/vue-query-v5');
28-
replace.sync({
29-
files: 'dist/runtime-v5/vue*(.d.ts|.d.mts|.js|.mjs)',
43+
replaceSync({
44+
file: 'dist/runtime-v5/vue*(.d.ts|.d.mts|.js|.mjs)',
3045
from: /@tanstack\/vue-query-v5/g,
3146
to: '@tanstack/vue-query',
3247
});

packages/plugins/tanstack-query/src/generator.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ import {
1414
} from '@zenstackhq/sdk';
1515
import { DataModel, DataModelFieldType, Model, isEnum, isTypeDef } from '@zenstackhq/sdk/ast';
1616
import { getPrismaClientImportSpec, supportCreateMany, type DMMF } from '@zenstackhq/sdk/prisma';
17-
import { paramCase } from 'change-case';
17+
import { lowerCaseFirst, upperCaseFirst, paramCase } from '@zenstackhq/runtime/local-helpers';
1818
import fs from 'fs';
19-
import { lowerCaseFirst } from 'lower-case-first';
2019
import path from 'path';
2120
import { Project, SourceFile, VariableDeclarationKind } from 'ts-morph';
2221
import { P, match } from 'ts-pattern';
23-
import { upperCaseFirst } from 'upper-case-first';
2422
import { name } from '.';
2523

2624
const supportedTargets = ['react', 'vue', 'svelte'];

packages/plugins/trpc/package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@
2626
"author": "ZenStack Team",
2727
"license": "MIT",
2828
"dependencies": {
29+
"@zenstackhq/runtime": "workspace:*",
2930
"@zenstackhq/sdk": "workspace:*",
30-
"change-case": "^4.1.2",
31-
"lower-case-first": "^2.0.2",
3231
"ts-morph": "^16.0.0",
33-
"tslib": "^2.4.1",
34-
"upper-case-first": "^2.0.2"
32+
"tslib": "^2.4.1"
3533
},
3634
"peerDependencies": {
37-
"zod": "^3.22.4"
35+
"zod": "^3.22.4"
3836
},
3937
"devDependencies": {
4038
"@trpc/next": "^10.32.0",

packages/plugins/trpc/src/client-helper/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { PluginError, type PluginOptions } from '@zenstackhq/sdk';
22
import { getPrismaClientImportSpec } from '@zenstackhq/sdk/prisma';
3+
import { lowerCaseFirst, upperCaseFirst } from '@zenstackhq/runtime/local-helpers';
34
import fs from 'fs';
4-
import { lowerCaseFirst } from 'lower-case-first';
55
import path from 'path';
66
import {
77
InterfaceDeclarationStructure,
@@ -10,7 +10,6 @@ import {
1010
SourceFile,
1111
StructureKind,
1212
} from 'ts-morph';
13-
import { upperCaseFirst } from 'upper-case-first';
1413
import { name } from '..';
1514
import { SupportedClientHelpers } from '../utils';
1615
import * as NextHelpers from './next';

packages/plugins/trpc/src/generator.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ import {
1212
} from '@zenstackhq/sdk';
1313
import { DataModel, isDataModel, Model } from '@zenstackhq/sdk/ast';
1414
import { getPrismaClientImportSpec, supportCreateMany, type DMMF } from '@zenstackhq/sdk/prisma';
15-
import { lowerCaseFirst } from 'lower-case-first';
15+
import { lowerCaseFirst, upperCaseFirst } from '@zenstackhq/runtime/local-helpers';
1616
import path from 'path';
1717
import { Project } from 'ts-morph';
18-
import { upperCaseFirst } from 'upper-case-first';
1918
import { name } from '.';
2019
import { createClientHelperEntries, generateClientTypingForModel } from './client-helper';
2120
import { project } from './project';
@@ -169,12 +168,12 @@ function createAppRouter(
169168
>(
170169
procedures: ProcRouterRecord
171170
) => CreateRouterInner<Config, ProcRouterRecord>;
172-
171+
173172
export type UnsetMarker = typeof unsetMarker;
174173
175174
export type ProcBuilder<Config extends BaseConfig> = ProcedureBuilder<
176175
ProcedureParams<Config, any, any, any, UnsetMarker, UnsetMarker, any>
177-
>;
176+
>;
178177
`);
179178
} else {
180179
appRouter.addImportDeclaration({

packages/plugins/trpc/src/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { type DMMF } from '@zenstackhq/sdk/prisma';
2-
import { lowerCaseFirst } from 'lower-case-first';
2+
import { lowerCaseFirst, upperCaseFirst } from '@zenstackhq/runtime/local-helpers';
33
import { CodeBlockWriter, SourceFile } from 'ts-morph';
4-
import { upperCaseFirst } from 'upper-case-first';
54

65
/**
76
* Supported client helper types

packages/plugins/trpc/tests/projects/nuxt-trpc-v10/package-lock.json

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/plugins/trpc/tests/projects/nuxt-trpc-v10/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"trpc-nuxt": "^0.10.22",
1818
"vue": "latest",
1919
"vue-router": "latest",
20-
"zod": "^3.22.4"
20+
"zod": "^3.22.4"
2121
},
2222
"devDependencies": {
2323
"esbuild": "^0.24.0",

0 commit comments

Comments
 (0)