@anthonylzq/simba.js 5.2.0 → 6.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/README.md +74 -304
- package/lib/index.js +42 -4
- package/lib/src/functions/api/database.js +133 -10
- package/lib/src/functions/api/index.js +4 -2
- package/lib/src/functions/api/network.js +71 -176
- package/lib/src/functions/eslint.js +40 -12
- package/lib/src/functions/ghat.js +65 -0
- package/lib/src/functions/gitignore.js +1 -0
- package/lib/src/functions/packageJson.js +11 -2
- package/lib/src/functions/tests.js +615 -0
- package/lib/src/index.js +23 -12
- package/lib/src/utils/constants.js +3 -0
- package/package.json +33 -16
|
@@ -8,11 +8,17 @@ module.exports = async projectName => {
|
|
|
8
8
|
const data = {
|
|
9
9
|
eslintContent: `{
|
|
10
10
|
"env": {
|
|
11
|
-
"node": true
|
|
11
|
+
"node": true,
|
|
12
|
+
"jest/globals": true
|
|
12
13
|
},
|
|
13
14
|
"root": true,
|
|
14
15
|
"parser": "@typescript-eslint/parser",
|
|
15
|
-
"plugins": [
|
|
16
|
+
"plugins": [
|
|
17
|
+
"@typescript-eslint",
|
|
18
|
+
"import",
|
|
19
|
+
"prettier",
|
|
20
|
+
"jest"
|
|
21
|
+
],
|
|
16
22
|
"extends": [
|
|
17
23
|
"standard",
|
|
18
24
|
"eslint:recommended",
|
|
@@ -23,7 +29,10 @@ module.exports = async projectName => {
|
|
|
23
29
|
"rules": {
|
|
24
30
|
"@typescript-eslint/no-var-requires": "off",
|
|
25
31
|
"@typescript-eslint/no-empty-interface": "off",
|
|
26
|
-
"arrow-parens": [
|
|
32
|
+
"arrow-parens": [
|
|
33
|
+
"error",
|
|
34
|
+
"as-needed"
|
|
35
|
+
],
|
|
27
36
|
"import/extensions": [
|
|
28
37
|
2,
|
|
29
38
|
{
|
|
@@ -35,9 +44,17 @@ module.exports = async projectName => {
|
|
|
35
44
|
"import/no-extraneous-dependencies": [
|
|
36
45
|
"error",
|
|
37
46
|
{
|
|
38
|
-
"devDependencies": [
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
"devDependencies": [
|
|
48
|
+
"**/*.test.ts",
|
|
49
|
+
"webpack.config.js",
|
|
50
|
+
"jest.config.ts"
|
|
51
|
+
],
|
|
52
|
+
"optionalDependencies": [
|
|
53
|
+
"**/*.test.ts"
|
|
54
|
+
],
|
|
55
|
+
"peerDependencies": [
|
|
56
|
+
"**/*.test.ts"
|
|
57
|
+
]
|
|
41
58
|
}
|
|
42
59
|
],
|
|
43
60
|
"max-len": [
|
|
@@ -53,8 +70,14 @@ module.exports = async projectName => {
|
|
|
53
70
|
}
|
|
54
71
|
],
|
|
55
72
|
"newline-before-return": "error",
|
|
56
|
-
"object-curly-spacing": [
|
|
57
|
-
|
|
73
|
+
"object-curly-spacing": [
|
|
74
|
+
"error",
|
|
75
|
+
"always"
|
|
76
|
+
],
|
|
77
|
+
"object-shorthand": [
|
|
78
|
+
"error",
|
|
79
|
+
"always"
|
|
80
|
+
],
|
|
58
81
|
"prefer-const": "error",
|
|
59
82
|
"prettier/prettier": [
|
|
60
83
|
"error",
|
|
@@ -69,11 +92,16 @@ module.exports = async projectName => {
|
|
|
69
92
|
"trailingComma": "none"
|
|
70
93
|
}
|
|
71
94
|
],
|
|
72
|
-
"radix": [
|
|
73
|
-
|
|
95
|
+
"radix": [
|
|
96
|
+
"error",
|
|
97
|
+
"as-needed"
|
|
98
|
+
],
|
|
99
|
+
"spaced-comment": [
|
|
100
|
+
"error",
|
|
101
|
+
"always"
|
|
102
|
+
]
|
|
74
103
|
}
|
|
75
|
-
}
|
|
76
|
-
`,
|
|
104
|
+
}`,
|
|
77
105
|
eslintFile: '.eslintrc',
|
|
78
106
|
eslintIgnoreContent: '/dist',
|
|
79
107
|
eslintIgnoreFile: '.eslintignore'
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const { platform } = require('os')
|
|
2
|
+
const { promisify } = require('util')
|
|
3
|
+
const exec = promisify(require('child_process').exec)
|
|
4
|
+
const writeFile = require('../utils/writeFile')
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {String} projectName
|
|
8
|
+
* @param {'yarn add'|'npm i'} manager
|
|
9
|
+
* @returns {Promise<void>}
|
|
10
|
+
*/
|
|
11
|
+
module.exports = async (projectName, manager) => {
|
|
12
|
+
const createFoldersCommand = `mkdir ${projectName}/.github \
|
|
13
|
+
${projectName}/.github/workflows`
|
|
14
|
+
const managerName = manager.split()[0]
|
|
15
|
+
|
|
16
|
+
if (platform() === 'win32')
|
|
17
|
+
await exec(createFoldersCommand.replaceAll('/', '\\'))
|
|
18
|
+
else await exec(createFoldersCommand)
|
|
19
|
+
|
|
20
|
+
const data = {
|
|
21
|
+
test: {
|
|
22
|
+
content: `name: Tests - ${projectName}
|
|
23
|
+
|
|
24
|
+
on: [push]
|
|
25
|
+
|
|
26
|
+
jobs:
|
|
27
|
+
test:
|
|
28
|
+
name: Testing Simba.js API
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
|
|
31
|
+
steps:
|
|
32
|
+
- name: Check out Git repository
|
|
33
|
+
uses: actions/checkout@v3
|
|
34
|
+
with:
|
|
35
|
+
fetch-depth: 0
|
|
36
|
+
|
|
37
|
+
- name: Set up Node.js
|
|
38
|
+
uses: actions/setup-node@v3
|
|
39
|
+
with:
|
|
40
|
+
node-version: 16.x
|
|
41
|
+
|
|
42
|
+
- name: Install Node.js dependencies
|
|
43
|
+
run: ${
|
|
44
|
+
managerName === 'yarn' ? 'yarn install --frozen-lockfile' : 'npm ci'
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
- name: Revert changes into the ${
|
|
48
|
+
managerName === 'yarn' ? 'yarn.lock' : 'package-lock.json'
|
|
49
|
+
} file
|
|
50
|
+
run: git checkout -- ${
|
|
51
|
+
managerName === 'yarn' ? 'yarn.lock' : 'package-lock.json'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- name: Run test
|
|
55
|
+
run: ${managerName === 'yarn' ? 'yarn' : 'npm run'} test:ci
|
|
56
|
+
env:
|
|
57
|
+
MONGO_URI: \${{ secrets.MONGO_URI }}
|
|
58
|
+
NODE_ENV: ci
|
|
59
|
+
`,
|
|
60
|
+
file: `${projectName}/.github/workflows/test.yml`
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
await writeFile(data.test.file, data.test.content)
|
|
65
|
+
}
|
|
@@ -10,7 +10,8 @@ module.exports = async ({
|
|
|
10
10
|
projectDescription,
|
|
11
11
|
projectVersion,
|
|
12
12
|
license,
|
|
13
|
-
mainFile
|
|
13
|
+
mainFile,
|
|
14
|
+
tests
|
|
14
15
|
}) => {
|
|
15
16
|
const data = {
|
|
16
17
|
content: '',
|
|
@@ -31,7 +32,14 @@ module.exports = async ({
|
|
|
31
32
|
"lint": "eslint src/* --ext .ts --fix",
|
|
32
33
|
"service": "nodemon",
|
|
33
34
|
"start": "node dist/index.js",
|
|
34
|
-
"release": "standard-version"
|
|
35
|
+
"release": "standard-version"\
|
|
36
|
+
${
|
|
37
|
+
tests
|
|
38
|
+
? `,
|
|
39
|
+
"test:ci": "jest --ci -i",
|
|
40
|
+
"test:local": "NODE_ENV=local jest --ci -i"`
|
|
41
|
+
: ''
|
|
42
|
+
}
|
|
35
43
|
},
|
|
36
44
|
"author": "${author}",${
|
|
37
45
|
license !== 'unlicensed'
|
|
@@ -53,4 +61,5 @@ module.exports = async ({
|
|
|
53
61
|
* @property {String} projectVersion
|
|
54
62
|
* @property {'unlicensed'|'mit'|'apache-2.0'|'mpl-2.0'|'lgpl-3.0'|'gpl-3.0'|'agpl-3.0'} license
|
|
55
63
|
* @property {String} mainFle
|
|
64
|
+
* @property {Boolean} tests
|
|
56
65
|
*/
|