create-cubeforge-game 0.3.16 → 0.4.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/package.json
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { readdirSync, readFileSync, existsSync } from 'fs'
|
|
3
|
+
import { join, resolve } from 'path'
|
|
4
|
+
|
|
5
|
+
const TEMPLATE_DIR = resolve(__dirname, '../default')
|
|
6
|
+
|
|
7
|
+
function collectTemplateFiles(dir: string): string[] {
|
|
8
|
+
const results: string[] = []
|
|
9
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
10
|
+
const fullPath = join(dir, entry.name)
|
|
11
|
+
if (entry.isDirectory()) {
|
|
12
|
+
results.push(...collectTemplateFiles(fullPath))
|
|
13
|
+
} else if (entry.name.endsWith('.template')) {
|
|
14
|
+
results.push(fullPath)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return results
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe('project template', () => {
|
|
21
|
+
const templateFiles = collectTemplateFiles(TEMPLATE_DIR)
|
|
22
|
+
|
|
23
|
+
it('contains at least one .template file', () => {
|
|
24
|
+
expect(templateFiles.length).toBeGreaterThan(0)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it.each(templateFiles.map((f) => [f.replace(TEMPLATE_DIR + '/', ''), f]))(
|
|
28
|
+
'%s exists and is non-empty',
|
|
29
|
+
(_name, filePath) => {
|
|
30
|
+
expect(existsSync(filePath)).toBe(true)
|
|
31
|
+
const content = readFileSync(filePath, 'utf-8')
|
|
32
|
+
expect(content.trim().length).toBeGreaterThan(0)
|
|
33
|
+
},
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
it('package.json.template has lint script', () => {
|
|
37
|
+
const pkgPath = join(TEMPLATE_DIR, 'package.json.template')
|
|
38
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
|
|
39
|
+
expect(pkg.scripts.lint).toBeDefined()
|
|
40
|
+
expect(pkg.scripts.lint).toContain('eslint')
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('package.json.template has format script', () => {
|
|
44
|
+
const pkgPath = join(TEMPLATE_DIR, 'package.json.template')
|
|
45
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
|
|
46
|
+
expect(pkg.scripts.format).toBeDefined()
|
|
47
|
+
expect(pkg.scripts.format).toContain('prettier')
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('includes eslint config template', () => {
|
|
51
|
+
expect(existsSync(join(TEMPLATE_DIR, '.eslintrc.cjs.template'))).toBe(true)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('includes prettier config template', () => {
|
|
55
|
+
expect(existsSync(join(TEMPLATE_DIR, '.prettierrc.template'))).toBe(true)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('tsconfig.json.template enables strict mode', () => {
|
|
59
|
+
const tsconfig = JSON.parse(
|
|
60
|
+
readFileSync(join(TEMPLATE_DIR, 'tsconfig.json.template'), 'utf-8'),
|
|
61
|
+
)
|
|
62
|
+
expect(tsconfig.compilerOptions.strict).toBe(true)
|
|
63
|
+
})
|
|
64
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: { browser: true, es2020: true },
|
|
4
|
+
extends: [
|
|
5
|
+
'eslint:recommended',
|
|
6
|
+
'plugin:@typescript-eslint/recommended',
|
|
7
|
+
'plugin:react-hooks/recommended',
|
|
8
|
+
],
|
|
9
|
+
ignorePatterns: ['dist'],
|
|
10
|
+
parser: '@typescript-eslint/parser',
|
|
11
|
+
rules: {
|
|
12
|
+
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
|
13
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
14
|
+
},
|
|
15
|
+
}
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
7
7
|
"build": "vite build",
|
|
8
|
-
"preview": "vite preview"
|
|
8
|
+
"preview": "vite preview",
|
|
9
|
+
"lint": "eslint src --ext ts,tsx",
|
|
10
|
+
"format": "prettier --write src"
|
|
9
11
|
},
|
|
10
12
|
"dependencies": {
|
|
11
13
|
"cubeforge": "latest",
|
|
@@ -15,7 +17,12 @@
|
|
|
15
17
|
"devDependencies": {
|
|
16
18
|
"@types/react": "^18.3.0",
|
|
17
19
|
"@types/react-dom": "^18.3.0",
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
21
|
+
"@typescript-eslint/parser": "^7.0.0",
|
|
18
22
|
"@vitejs/plugin-react": "^4.0.0",
|
|
23
|
+
"eslint": "^8.57.0",
|
|
24
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
25
|
+
"prettier": "^3.2.0",
|
|
19
26
|
"typescript": "^5.4.0",
|
|
20
27
|
"vite": "^5.0.0"
|
|
21
28
|
}
|