Skip to content

Commit dbb3183

Browse files
committed
build: updated deps and fixed eslint errors
1 parent fb3b3a5 commit dbb3183

File tree

11 files changed

+69
-33
lines changed

11 files changed

+69
-33
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
"version": "node scripts/postversion.js && git add files/empty-project/package.json"
2929
},
3030
"dependencies": {
31-
"@tsparticles/eslint-config": "^2.0.2",
31+
"@tsparticles/eslint-config": "^2.0.3",
3232
"@tsparticles/prettier-config": "^2.0.1",
3333
"@tsparticles/tsconfig": "^2.0.1",
34-
"@tsparticles/webpack-plugin": "^2.0.2",
34+
"@tsparticles/webpack-plugin": "^2.0.3",
3535
"@typescript-eslint/eslint-plugin": "^6.14.0",
3636
"@typescript-eslint/parser": "^6.14.0",
3737
"commander": "^11.1.0",

pnpm-lock.yaml

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

src/build/build-distfiles.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ export async function buildDistFiles(basePath: string): Promise<boolean> {
3333
libObj.peerDependencies = JSON.parse(JSON.stringify(pkgInfo.peerDependencies).replaceAll("workspace:", ""));
3434
}
3535

36-
fs.writeFileSync(libPackage, `${JSON.stringify(libObj, undefined, 2)}\n`, "utf8");
36+
const jsonIndent = 2;
37+
38+
fs.writeFileSync(libPackage, `${JSON.stringify(libObj, undefined, jsonIndent)}\n`, "utf8");
3739

3840
console.log(`package.dist.json updated successfully to version ${pkgInfo.version}`);
3941

src/build/build-diststats.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ async function getFolderStats(folderPath: string, bundlePath?: string): Promise<
2828
const dir = await fs.promises.opendir(folderPath);
2929

3030
for await (const dirent of dir) {
31+
const increment = 1;
32+
3133
if (dirent.isDirectory()) {
3234
const subDirStats = await getFolderStats(path.join(folderPath, dirent.name), bundlePath);
3335

34-
stats.totalFolders += subDirStats.totalFolders + 1;
36+
stats.totalFolders += subDirStats.totalFolders + increment;
3537
stats.totalFiles += subDirStats.totalFiles;
3638
stats.totalSize += subDirStats.totalSize;
3739
} else {

src/build/build-eslint.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ export async function lint(ci: boolean): Promise<boolean> {
2424
await ESLint.outputFixes(results);
2525

2626
const formatter = await eslint.loadFormatter("stylish"),
27-
resultText = formatter.format(results);
27+
resultText = formatter.format(results),
28+
minimumLength = 0;
2829

29-
if (errors.length > 0) {
30+
if (errors.length > minimumLength) {
3031
const messages = errors.map(t =>
3132
t.messages.map(m => `${t.filePath} (${m.line},${m.column}): ${m.message}`).join("\n"),
3233
);

src/build/build-tsc.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ import fs from "fs-extra";
22
import path from "path";
33
import ts from "typescript";
44

5+
const enum ExitCodes {
6+
OK,
7+
EmitErrors,
8+
NoDataOrOptions,
9+
NoOptions,
10+
ParseError,
11+
}
12+
513
/**
614
* @param basePath -
715
* @param file -
@@ -104,21 +112,21 @@ async function compile(basePath: string, type: "browser" | "cjs" | "esm" | "type
104112
}
105113

106114
if (!data && !options) {
107-
return 2;
115+
return ExitCodes.NoDataOrOptions;
108116
}
109117

110118
if (!options && data) {
111119
options = JSON.parse(data);
112120
}
113121

114122
if (!options) {
115-
return 3;
123+
return ExitCodes.NoOptions;
116124
}
117125

118126
const parsed = ts.parseJsonConfigFileContent(options, ts.sys, basePath);
119127

120128
if (!parsed) {
121-
return 4;
129+
return ExitCodes.ParseError;
122130
}
123131

124132
const program = ts.createProgram(parsed.fileNames, parsed.options),
@@ -131,16 +139,21 @@ async function compile(basePath: string, type: "browser" | "cjs" | "esm" | "type
131139
failed = failed || diagnostic.category === ts.DiagnosticCategory.Error;
132140

133141
if (diagnostic.file) {
134-
const { line, character } = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start ?? 0),
135-
message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
136-
137-
console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
142+
const startingPos = 0,
143+
{ line, character } = ts.getLineAndCharacterOfPosition(
144+
diagnostic.file,
145+
diagnostic.start ?? startingPos,
146+
),
147+
message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"),
148+
increment = 1;
149+
150+
console.log(`${diagnostic.file.fileName} (${line + increment},${character + increment}): ${message}`);
138151
} else {
139152
console.log(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
140153
}
141154
});
142155

143-
const exitCode = emitResult.emitSkipped || failed ? 1 : 0;
156+
const exitCode = emitResult.emitSkipped || failed ? ExitCodes.EmitErrors : ExitCodes.OK;
144157

145158
console.log(`TSC for ${type} done with exit code: '${exitCode}'.`);
146159

src/build/build.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ buildCommand.action(async (argPath: string) => {
8989
const newStats = await getDistStats(basePath),
9090
diffSize = newStats.totalSize - oldStats.totalSize,
9191
bundleDiffSize = newStats.bundleSize - oldStats.bundleSize,
92-
bundleSizeIncreased = bundleDiffSize > 0,
92+
minSize = 0,
93+
bundleSizeIncreased = bundleDiffSize > minSize,
9394
outputFunc = bundleSizeIncreased ? console.warn : console.info,
9495
texts = [
9596
!bundleDiffSize
@@ -99,7 +100,7 @@ buildCommand.action(async (argPath: string) => {
99100
} (${Math.abs(bundleDiffSize)}B)`,
100101
!diffSize
101102
? "Size unchanged"
102-
: `Size ${diffSize > 0 ? "increased" : "decreased"} from ${oldStats.totalSize} to ${
103+
: `Size ${diffSize > minSize ? "increased" : "decreased"} from ${oldStats.totalSize} to ${
103104
newStats.totalSize
104105
} (${Math.abs(diffSize)}B)`,
105106
`Files count changed from ${oldStats.totalFiles} to ${newStats.totalFiles} (${

src/create/plugin/create-plugin.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,13 @@ async function updateReadmeFile(destPath: string, name: string, description: str
9898
capitalizedName = capitalize(name, "-", " "),
9999
camelizedName = camelize(capitalizedName),
100100
dashedName = dash(camelizedName),
101-
repoPath = repoUrl.includes("github.com")
102-
? repoUrl.substring(repoUrl.indexOf("github.com/") + 11, repoUrl.indexOf(".git"))
101+
stringSearch = "github.com",
102+
trailingSlashSearch = "github.com/",
103+
repoPath = repoUrl.includes(stringSearch)
104+
? repoUrl.substring(
105+
repoUrl.indexOf(trailingSlashSearch) + trailingSlashSearch.length,
106+
repoUrl.indexOf(".git"),
107+
)
103108
: "tsparticles/plugin-template";
104109

105110
await replaceTokensInFile({

src/create/preset/create-preset.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,13 @@ async function updateReadmeFile(destPath: string, name: string, description: str
116116
const capitalizedName = capitalize(name, "-", " "),
117117
camelizedName = camelize(capitalizedName),
118118
dashedName = dash(camelizedName),
119-
repoPath = repoUrl.includes("github.com")
120-
? repoUrl.substring(repoUrl.indexOf("github.com/") + 11, repoUrl.indexOf(".git"))
119+
stringSearch = "github.com",
120+
trailingSlashSearch = "github.com/",
121+
repoPath = repoUrl.includes(stringSearch)
122+
? repoUrl.substring(
123+
repoUrl.indexOf(trailingSlashSearch) + trailingSlashSearch.length,
124+
repoUrl.indexOf(".git"),
125+
)
121126
: "tsparticles/preset-template";
122127

123128
await replaceTokensInFile({

src/create/shape/create-shape.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,13 @@ async function updateReadmeFile(destPath: string, name: string, description: str
9797
const capitalizedName = capitalize(name, "-", " "),
9898
camelizedName = camelize(capitalizedName),
9999
dashedName = dash(camelizedName),
100-
repoPath = repoUrl.includes("github.com")
101-
? repoUrl.substring(repoUrl.indexOf("github.com/") + 11, repoUrl.indexOf(".git"))
100+
stringSearch = "github.com",
101+
trailingSlashSearch = "github.com/",
102+
repoPath = repoUrl.includes(stringSearch)
103+
? repoUrl.substring(
104+
repoUrl.indexOf(trailingSlashSearch) + trailingSlashSearch.length,
105+
repoUrl.indexOf(".git"),
106+
)
102107
: "tsparticles/shape-template";
103108

104109
await replaceTokensInFile({

0 commit comments

Comments
 (0)