Skip to content

Commit

Permalink
Merge pull request #1 from caipng/dev
Browse files Browse the repository at this point in the history
Setup project structure and workflow
  • Loading branch information
caipng authored Sep 10, 2023
2 parents 4b39493 + 7e0cb0c commit 4b6d452
Show file tree
Hide file tree
Showing 20 changed files with 8,777 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-env node */
module.exports = {
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
root: true,
env: {
node: true,
},
ignorePatterns: ["cparser.js", "src/*.js", "src/*.cjs"],
};
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on: [push]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm install -g grunt-cli
- run: npm ci
- run: grunt build
- run: npm test
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
Expand Down Expand Up @@ -128,3 +127,9 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

dist/*.js
dist/*.js.map
lib/
.tscache
src/cparser.js
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Ignore artifacts:
build
coverage
lib

# Ignore all HTML files:
**/*.html
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
89 changes: 89 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
module.exports = (grunt) => {
require("load-grunt-tasks")(grunt);

grunt.registerTask("build", "build", ["clean", "peg", "copy", "ts", "dist"]);

grunt.registerTask("dist", "bundle into distribution version", [
"browserify",
"babel",
"uglify",
]);

grunt.registerTask("default", "watch & compile", ["build", "watch"]);

const pkg = grunt.file.readJSON("package.json");
return grunt.initConfig({
pkg,

copy: {
build: {
cwd: "src",
src: ["**/*.js"],
dest: "lib",
expand: true,
},
},

clean: {
build: {
src: ["lib", "dist/cviz.*"],
},
},

browserify: {
dist: {
files: {
"dist/cviz.js": ["lib/index.js"],
},
},
},

uglify: {
dist: {
files: {
"dist/cviz.es5.min.js": ["dist/cviz.es5.js"],
},
},
},

babel: {
options: {
sourceMap: true,
presets: ["@babel/preset-env"],
},
dist: {
files: {
"dist/cviz.es5.js": "dist/cviz.js",
},
},
},

peg: {
build: {
cwd: "parsers",
src: ["**/*.pegjs"],
dest: "src",
ext: ".js",
expand: true,
},
},

ts: {
default: {
src: ["src/**/*.ts"],
tsconfig: "./tsconfig.json",
},
},

watch: {
peg: {
files: "parser/**/*.pegjs",
tasks: ["newer:peg"],
},
copy: {
files: ["src/**/*.js"],
tasks: ["newer:copy"],
},
},
});
};
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# c-viz

A C parser+interpreter+visualizer written in JS that runs in the browser.

Workflow inspired by https://github.com/felixhao28/JSCPP

- `grunt` to watch & build
- `npm run build` to build
- `npm run test` to run tests
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1. Setup prepush hooks
Empty file added dist/index.html
Empty file.
Loading

0 comments on commit 4b6d452

Please sign in to comment.