@arianrhodsandlot/vite-plus-config 1.0.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -30,6 +30,7 @@ for (const [name, extension = name] of [
30
30
  ["svelte"],
31
31
  ["astro"]
32
32
  ]) if (isPackageInstalled(name)) fileTypes.push(extension);
33
+ if (isPackageInstalled("astro")) oxlintrc.globals = { Astro: "readonly" };
33
34
  const glob = `*.{${fileTypes.join(",")}}`;
34
35
  const config = defineConfig({
35
36
  fmt: oxfmtrc,
package/package.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "name": "@arianrhodsandlot/vite-plus-config",
3
- "version": "1.0.2",
4
3
  "description": "A set of predefined Vite+ config.",
5
4
  "keywords": [
6
5
  "vite-plus"
@@ -12,7 +11,8 @@
12
11
  },
13
12
  "repository": "arianrhodsandlot/vite-plus-config",
14
13
  "files": [
15
- "dist"
14
+ "dist",
15
+ "scripts"
16
16
  ],
17
17
  "type": "module",
18
18
  "module": "./dist/index.mjs",
@@ -26,19 +26,19 @@
26
26
  },
27
27
  "./package.json": "./package.json"
28
28
  },
29
+ "scripts": {
30
+ "build": "vp pack",
31
+ "postinstall": "node scripts/postinstall.ts"
32
+ },
29
33
  "dependencies": {
30
- "@arianrhodsandlot/oxc-config": "^1.2.0",
31
- "@types/node": "^25.5.0"
34
+ "@arianrhodsandlot/oxc-config": "^1.2.3",
35
+ "@types/node": "^25.6.2"
32
36
  },
33
37
  "devDependencies": {
34
- "simple-git-hooks": "2.13.1",
35
- "typescript": "5.9.3",
36
- "vite-plus": "0.1.12"
38
+ "@tsconfig/node-ts": "23.6.4",
39
+ "typescript": "6.0.3",
40
+ "vite-plus": "0.1.20"
37
41
  },
38
- "simple-git-hooks": {
39
- "pre-commit": "pnpm vp staged"
40
- },
41
- "scripts": {
42
- "build": "vp pack"
43
- }
44
- }
42
+ "packageManager": "pnpm@11.0.8",
43
+ "version": "1.2.0"
44
+ }
@@ -0,0 +1,85 @@
1
+ import { exec } from 'node:child_process'
2
+ import { access, constants, mkdir, writeFile, chmod, readFile } from 'node:fs/promises'
3
+ import { resolve } from 'node:path'
4
+ import { promisify } from 'node:util'
5
+
6
+ const execAsync = promisify(exec)
7
+
8
+ const cwd = process.env.INIT_CWD || process.cwd()
9
+
10
+ async function shouldSkip(): Promise<boolean> {
11
+ const envOptOut = process.env.SKIP_VITE_PLUS_CONFIG_HOOK
12
+ if (envOptOut === '1' || envOptOut === 'true') {
13
+ return true
14
+ }
15
+
16
+ if (
17
+ process.env.CI ||
18
+ process.env.CONTINUOUS_INTEGRATION ||
19
+ process.env.BUILD_NUMBER ||
20
+ process.env.BUILD_ID ||
21
+ process.env.CI_NAME ||
22
+ process.env.DRONE ||
23
+ process.env.GITHUB_ACTIONS ||
24
+ process.env.GITLAB_CI ||
25
+ process.env.CIRCLECI ||
26
+ process.env.TRAVIS ||
27
+ process.env.APPVEYOR ||
28
+ process.env.TEAMCITY_VERSION ||
29
+ process.env.TF_BUILD
30
+ ) {
31
+ return true
32
+ }
33
+
34
+ try {
35
+ const raw = await readFile(resolve(cwd, 'package.json'), 'utf8')
36
+ const pkg = JSON.parse(raw)
37
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies, ...pkg.peerDependencies, ...pkg.optionalDependencies }
38
+ if (!('@arianrhodsandlot/vite-plus-config' in deps)) {
39
+ return true
40
+ }
41
+ } catch {
42
+ return true
43
+ }
44
+
45
+ return false
46
+ }
47
+
48
+ async function pathExists(path: string): Promise<boolean> {
49
+ try {
50
+ await access(path, constants.F_OK)
51
+ return true
52
+ } catch {
53
+ return false
54
+ }
55
+ }
56
+
57
+ async function main() {
58
+ if (await shouldSkip()) {
59
+ return
60
+ }
61
+
62
+ let hooksDir: string | undefined
63
+
64
+ try {
65
+ const { stdout } = await execAsync('git rev-parse --git-path hooks', {
66
+ cwd,
67
+ encoding: 'utf8',
68
+ })
69
+ hooksDir = stdout.trim()
70
+ } catch {}
71
+
72
+ if (!hooksDir) {
73
+ return
74
+ }
75
+
76
+ if (!(await pathExists(hooksDir))) {
77
+ await mkdir(hooksDir, { recursive: true })
78
+ }
79
+
80
+ const preCommitPath = resolve(hooksDir, 'pre-commit')
81
+ await writeFile(preCommitPath, 'vp staged\n', 'utf8')
82
+ await chmod(preCommitPath, 0o755)
83
+ }
84
+
85
+ await main()