Skip to content

Commit 12cb521

Browse files
committed
init
0 parents  commit 12cb521

40 files changed

+5875
-0
lines changed

.devcontainer/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM docker.io/node:22.11.0
2+
3+
USER node

.devcontainer/devcontainer.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"build": {
3+
"context": ".",
4+
"dockerfile": "./Dockerfile"
5+
},
6+
"customizations": {
7+
"vscode": {
8+
"extensions": [
9+
"dbaeumer.vscode-eslint",
10+
"esbenp.prettier-vscode",
11+
"streetsidesoftware.code-spell-checker"
12+
]
13+
}
14+
},
15+
"name": "Node.js 22"
16+
}

.github/workflows/release.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build-bundle:
9+
permissions: write-all
10+
runs-on: ubuntu-latest
11+
env:
12+
ANCA_CI: true
13+
name: Build bundle
14+
steps:
15+
- uses: actions/checkout@v4
16+
name: Checkout repo
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 22.11.0
20+
name: Install Node.js
21+
- run: npm ci
22+
name: Install dependencies
23+
- run: npm run build:bundle
24+
name: Build bundle
25+
- run: |
26+
mv build/bundle/index.js build/bundle/${{ github.event.repository.name }}-${{ github.ref_name }}.js
27+
shell: bash
28+
name: Rename bundle
29+
- uses: softprops/action-gh-release@v1
30+
with:
31+
files: |
32+
build/bundle/${{ github.event.repository.name }}-${{ github.ref_name }}.js
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
name: Attach bundle to release

.github/workflows/test.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
7+
jobs:
8+
test-commit:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
node: [18.20.4, 20.18.0, 22.11.0, 23.2.0]
13+
name: Test repo on Node.js ${{ matrix.node }}
14+
steps:
15+
- uses: actions/checkout@v4
16+
name: "Checkout repo"
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: ${{ matrix.node }}
20+
registry-url: https://registry.npmjs.org/
21+
name: "Install Node.js"
22+
- run: npm ci
23+
name: "Install dependencies"
24+
- run: npm test
25+
name: "Run tests"

.gitignore

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Editor directories and files
2+
.idea
3+
.DS_Store
4+
*.suo
5+
*.ntvs*
6+
*.njsproj
7+
*.sln
8+
*.sw?
9+
.vscode
10+
11+
# Logs
12+
logs
13+
*.log
14+
15+
# Runtime data
16+
pids
17+
*.pid
18+
*.seed
19+
*.pid.lock
20+
*.lock
21+
22+
# Temp folder
23+
tmp
24+
25+
# Built sources
26+
dist
27+
build
28+
*.spec
29+
30+
# Dependency directories
31+
node_modules/
32+
jspm_packages/
33+
.yarn/cache
34+
.yarn/unplugged
35+
.yarn/build-state.yml
36+
.yarn/install-state.gz
37+
.pnp.*
38+
.yarn-integrity
39+
40+
# Local settings
41+
.env
42+
.env.development.local
43+
.env.test.local
44+
.env.production.local
45+
.env.local
46+
47+
# Node.js logs
48+
npm-debug.log*
49+
yarn-debug.log*
50+
yarn-error.log*
51+
pnpm-debug.log*
52+
lerna-debug.log*
53+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
54+
55+
# Output of 'npm pack'
56+
*.tgz

.prettierignore

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# General
2+
**/.git
3+
**/.svn
4+
**/.hg
5+
6+
# Binaries
7+
/bin
8+
9+
# Devcontainer
10+
.devcontainer
11+
12+
# Node.js
13+
**/node_modules
14+
package-lock.json
15+
16+
# Distributions
17+
/build
18+
/dist
19+
20+
# Cinnabar Meta
21+
**/cinnabar.js
22+
**/cinnabar.ts
23+
cinnabar.json
24+
CHANGELOG.md
25+
26+
# Anca
27+
anca.json
28+
esbuild.js
29+
eslint.config.js
30+
openapi.json

.prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

CONTRIBUTING.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Contributing
2+
3+
Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or create a pull request.
4+
5+
## Installation
6+
7+
We support [Devcontainers](https://containers.dev/). You can use the provided development container to work on this project. The development container includes all the necessary tools and dependencies to work on this project.
8+
9+
Otherwise, download, install and configure [Node.js](https://nodejs.org/en/download/).
10+
11+
Then, run the following commands to install the dependencies and run the tests:
12+
13+
```bash
14+
npm ci
15+
npm test
16+
```

LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
There is nothing we can do

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# SnapCRUD
2+
3+
> **DISCLAIMER**: This project is not production ready. All versions below 1.0.0 should be considered unstable
4+
5+
## Installation
6+
7+
## Contributing
8+
9+
Visit [`CONTRIBUTING.md`](CONTRIBUTING.md).
10+
11+
## License
12+
13+
Visit [`LICENSE`](LICENSE).
14+
15+
## Anca
16+
17+
This repository is a part of [Anca](https://github.com/cinnabar-forge/anca) standardization project. Parts of the files and code are generated by Anca.

anca.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"development": {
3+
"nodejsOpenapi": {
4+
"modelsLocation": "./src/types/openapi.ts",
5+
"modelsModule": "../types/openapi.js",
6+
"modelsLocationType": "file"
7+
},
8+
"readme": {}
9+
},
10+
"namings": {
11+
"text": "SnapCRUD",
12+
"npmPackage": "snapcrud"
13+
},
14+
"type": "api",
15+
"stack": "nodejs"
16+
}

esbuild.js

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import { build, context } from "esbuild";
2+
import fs from "fs";
3+
import path from "path";
4+
import { spawn } from "child_process";
5+
6+
const getNodeModules = () => {
7+
const nodeModulesPath = path.resolve(import.meta.dirname, "node_modules");
8+
if (!fs.existsSync(nodeModulesPath)) {
9+
return [];
10+
}
11+
12+
return fs.readdirSync(nodeModulesPath).filter((module) => {
13+
return !module.startsWith(".");
14+
});
15+
};
16+
17+
const markBuild = () => {
18+
if (process.env.NODE_ENV === "production") {
19+
return `""`;
20+
}
21+
22+
const datetime = new Date(Date.now())
23+
.toISOString()
24+
.replaceAll("-", "")
25+
.replaceAll(":", "")
26+
.replace("T", ".")
27+
.replace("Z", "")
28+
.split(".");
29+
30+
const build = datetime[0] + "_" + datetime[1];
31+
32+
return `"+next.${build}"`;
33+
}
34+
35+
const IS_WATCH_MODE = process.argv[2] === "watch";
36+
const IS_NPM_BUNDLE = process.argv[2] !== "full";
37+
const ARGUMENTS = process.argv[3] || "";
38+
39+
const ESBUILD_NAME = IS_NPM_BUNDLE ? "NPM Bundle" : "Full Bundle";
40+
const OUT_FILE = IS_NPM_BUNDLE ? "dist/index.js" : "build/bundle/index.js";
41+
42+
const nodeModules = IS_NPM_BUNDLE ? getNodeModules() : [];
43+
44+
const myVars = {
45+
'process.env.ANCA_BUILD_PREFIX': markBuild(),
46+
}
47+
48+
const buildOptions = {
49+
bundle: true,
50+
define: myVars,
51+
entryPoints: ["src/index.ts"],
52+
external: nodeModules,
53+
format: IS_NPM_BUNDLE ? "esm" : "cjs",
54+
outfile: OUT_FILE,
55+
platform: "node",
56+
};
57+
58+
let childProcess = null;
59+
60+
const runOutputFile = () => {
61+
if (childProcess) {
62+
childProcess.kill();
63+
}
64+
childProcess = spawn("node", [OUT_FILE, ...ARGUMENTS.split(" ")], {
65+
stdio: "inherit",
66+
});
67+
};
68+
69+
const cleanUp = () => {
70+
if (childProcess) {
71+
childProcess.kill();
72+
}
73+
process.exit();
74+
};
75+
76+
const watchOutputFile = () => {
77+
fs.watch(OUT_FILE, (eventType) => {
78+
if (eventType === "change") {
79+
runOutputFile();
80+
}
81+
});
82+
};
83+
84+
process.on("exit", cleanUp);
85+
process.on("SIGINT", cleanUp);
86+
process.on("SIGTERM", cleanUp);
87+
process.on("uncaughtException", cleanUp);
88+
89+
if (IS_WATCH_MODE) {
90+
context(buildOptions)
91+
.then(async (ctx) => {
92+
await ctx.watch();
93+
console.log(
94+
`Watching ${buildOptions.entryPoints[0]}... (out: ${ESBUILD_NAME} '${OUT_FILE}')`,
95+
);
96+
runOutputFile();
97+
watchOutputFile();
98+
})
99+
.catch((e) => {
100+
console.error(
101+
`Error setting up watch mode for ${ESBUILD_NAME}: ${e.message}`,
102+
);
103+
process.exit(1);
104+
});
105+
} else {
106+
build(buildOptions)
107+
.then(() => {
108+
console.log(`${ESBUILD_NAME} has been built to ${OUT_FILE}`);
109+
})
110+
.catch((e) => {
111+
console.error(`Error building ${ESBUILD_NAME}: ${e.message}`);
112+
process.exit(1);
113+
});
114+
}

eslint.config.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import cinnabarPlugin from "@cinnabar-forge/eslint-plugin";
2+
3+
// [ANCA-ANCHOR-CUSTOM-CONTENT-START]
4+
5+
const files = ["src/**/*.ts"];
6+
const ignores = ["bin/**/*", "build/**/*", "dist/**/*"];
7+
const rules = {
8+
"@typescript-eslint/no-explicit-any": "off",
9+
"jsdoc/require-param-description": "off",
10+
"jsdoc/require-param-type": "off",
11+
"jsdoc/require-returns": "off",
12+
"jsdoc/require-returns-type": "off",
13+
"security/detect-non-literal-fs-filename": "off",
14+
"security/detect-object-injection": "off",
15+
};
16+
17+
// [ANCA-ANCHOR-CUSTOM-CONTENT-END]
18+
19+
export default [
20+
...cinnabarPlugin.default.map((config) => ({
21+
...config,
22+
files,
23+
})),
24+
{
25+
files,
26+
rules,
27+
},
28+
{
29+
ignores,
30+
},
31+
];

0 commit comments

Comments
 (0)