Skip to content

Commit b0660e7

Browse files
committed
Change private detection
1 parent b6f3fc3 commit b0660e7

File tree

10 files changed

+49
-47
lines changed

10 files changed

+49
-47
lines changed

apps/builder/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
"@types/react": "^18.2.70",
130130
"@types/react-dom": "^18.2.25",
131131
"@webstudio-is/tsconfig": "workspace:*",
132+
"fast-glob": "^3.3.2",
132133
"html-tags": "^4.0.0",
133134
"react-router-dom": "^6.28.1",
134135
"react-test-renderer": "18.3.0-canary-14898b6a9-20240318",

apps/builder/vite.config.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,17 @@ import {
99
getAuthorizationServerOrigin,
1010
isBuilderUrl,
1111
} from "./app/shared/router-utils/origins";
12-
import { readFileSync, readdirSync, existsSync } from "node:fs";
12+
import { readFileSync, existsSync } from "node:fs";
13+
import fg from "fast-glob";
1314

14-
const isFolderEmpty = (folderPath: string) => {
15-
if (!existsSync(folderPath)) {
16-
return true; // Folder does not exist
17-
}
18-
const contents = readdirSync(folderPath);
19-
20-
return contents.length === 0;
21-
};
15+
const rootDir = ["..", "../..", "../../.."]
16+
.map((dir) => path.join(__dirname, dir))
17+
.find((dir) => existsSync(path.join(dir, ".git")));
2218

23-
const hasPrivateFolders = !isFolderEmpty(
24-
path.join(__dirname, "../../packages/sdk-components-animation/private-src")
25-
);
19+
const hasPrivateFolders =
20+
fg.sync([path.join(rootDir ?? "", "packages/*/private-src/*")], {
21+
ignore: ["**/node_modules/**"],
22+
}).length > 0;
2623

2724
export default defineConfig(({ mode }) => {
2825
if (mode === "test") {

fixtures/webstudio-features/.template/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@
88
"@webstudio-is/sdk-components-react-radix": "workspace:*",
99
"@webstudio-is/sdk-components-react-router": "workspace:*",
1010
"webstudio": "workspace:*"
11+
},
12+
"devDependencies": {
13+
"fast-glob": "^3.3.2"
1114
}
1215
}

fixtures/webstudio-features/.template/vite.config.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@ import { dedupeMeta } from "./proxy-emulator/dedupe-meta";
66
import { existsSync, readdirSync } from "fs";
77
// @ts-ignore
88
import path from "path";
9+
// @ts-ignore
10+
import fg from "fast-glob";
911

10-
const isFolderEmpty = (folderPath: string) => {
11-
if (!existsSync(folderPath)) {
12-
return true; // Folder does not exist
13-
}
14-
const contents = readdirSync(folderPath);
15-
16-
return contents.length === 0;
17-
};
12+
const rootDir = ["..", "../..", "../../.."]
13+
.map((dir) => path.join(__dirname, dir))
14+
.find((dir) => existsSync(path.join(dir, ".git")));
1815

19-
const hasPrivateFolders = !isFolderEmpty(
20-
path.join(__dirname, "../../packages/sdk-components-animation/private-src")
21-
);
16+
const hasPrivateFolders =
17+
fg.sync([path.join(rootDir ?? "", "packages/*/private-src/*")], {
18+
ignore: ["**/node_modules/**"],
19+
}).length > 0;
2220

2321
const conditions = hasPrivateFolders
2422
? ["webstudio-private", "webstudio"]

fixtures/webstudio-features/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"webstudio": "workspace:*",
3535
"@types/react": "^18.2.70",
3636
"@types/react-dom": "^18.2.25",
37-
"typescript": "5.7.3"
37+
"typescript": "5.7.3",
38+
"fast-glob": "^3.3.2"
3839
},
3940
"engines": {
4041
"node": ">=20.0.0"

fixtures/webstudio-features/vite.config.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@ import { dedupeMeta } from "./proxy-emulator/dedupe-meta";
66
import { existsSync, readdirSync } from "fs";
77
// @ts-ignore
88
import path from "path";
9+
// @ts-ignore
10+
import fg from "fast-glob";
911

10-
const isFolderEmpty = (folderPath: string) => {
11-
if (!existsSync(folderPath)) {
12-
return true; // Folder does not exist
13-
}
14-
const contents = readdirSync(folderPath);
15-
16-
return contents.length === 0;
17-
};
12+
const rootDir = ["..", "../..", "../../.."]
13+
.map((dir) => path.join(__dirname, dir))
14+
.find((dir) => existsSync(path.join(dir, ".git")));
1815

19-
const hasPrivateFolders = !isFolderEmpty(
20-
path.join(__dirname, "../../packages/sdk-components-animation/private-src")
21-
);
16+
const hasPrivateFolders =
17+
fg.sync([path.join(rootDir ?? "", "packages/*/private-src/*")], {
18+
ignore: ["**/node_modules/**"],
19+
}).length > 0;
2220

2321
const conditions = hasPrivateFolders
2422
? ["webstudio-private", "webstudio"]

packages/sdk-components-animation/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"@webstudio-is/sdk-components-react": "workspace:*",
7373
"@webstudio-is/template": "workspace:*",
7474
"@webstudio-is/tsconfig": "workspace:*",
75+
"fast-glob": "^3.3.2",
7576
"playwright": "^1.50.1",
7677
"react": "18.3.0-canary-14898b6a9-20240318",
7778
"react-dom": "18.3.0-canary-14898b6a9-20240318",

packages/sdk-components-animation/vitest.config.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import { defineConfig } from "vitest/config";
22
import { existsSync, readdirSync } from "node:fs";
33
import path from "node:path";
4+
import fg from "fast-glob";
45

5-
const isFolderEmpty = (folderPath: string) => {
6-
if (!existsSync(folderPath)) {
7-
return true; // Folder does not exist
8-
}
9-
const contents = readdirSync(folderPath);
6+
const rootDir = ["..", "../..", "../../.."]
7+
.map((dir) => path.join(__dirname, dir))
8+
.find((dir) => existsSync(path.join(dir, ".git")));
109

11-
return contents.length === 0;
12-
};
13-
14-
const hasPrivateFolders = !isFolderEmpty(
15-
path.join(__dirname, "../../packages/sdk-components-animation/private-src")
16-
);
10+
const hasPrivateFolders =
11+
fg.sync([path.join(rootDir ?? "", "packages/*/private-src/*")], {
12+
ignore: ["**/node_modules/**"],
13+
}).length > 0;
1714

1815
const conditions = hasPrivateFolders
1916
? ["webstudio-private", "webstudio"]

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)