Skip to content

Commit

Permalink
Fix deploy and lint (#208)
Browse files Browse the repository at this point in the history
* fix-deploy lint all
  • Loading branch information
mmcardle authored Dec 21, 2024
1 parent 7a3e20d commit 64095f7
Show file tree
Hide file tree
Showing 46 changed files with 560 additions and 785 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-v3-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-yarn-v4-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v3-
${{ runner.os }}-yarn-v4-
- run: yarn install
- run: yarn build
Expand All @@ -39,6 +39,30 @@ jobs:
name: djangobuilder.io_dist
path: ./packages/djangobuilder.io/dist

lint:
name: Lint
needs: [build]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 18

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-v4-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-v4-
- run: yarn
- run: yarn lint

smoke_tests:
name: Core - Smoke tests
needs: [build]
Expand Down
4 changes: 2 additions & 2 deletions lib/djangobuilder-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"typescript": "^4.8.4"
},
"scripts": {
"lint": "eslint .",
"fix-lint": "eslint . --fix",
"lint": "eslint src/ tests/ --ext .ts",
"fix-lint": "eslint src/ tests/ --fix",
"test_smoke": "npx tsc && npx ts-node src/smoketest.ts",
"test": "jest .",
"cli": "tsc -t es5 src/cli.ts --outDir dist --esModuleInterop && node dist/cli.js render"
Expand Down
5 changes: 4 additions & 1 deletion lib/djangobuilder-core/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import type {
IFieldTestDefault,
IRelationshipType,
IRelatedField,
IParentField,
IParentField



} from "./types";
import { DjangoVersion } from "./types";
import { uniqueId } from "./util";
Expand Down
37 changes: 32 additions & 5 deletions lib/djangobuilder-core/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,33 @@ console.log("Running CLI:", args);

const command = args[0];

interface JSONProject {
name: string;
description: string;
version?: DjangoVersion;
channels?: boolean;
htmx?: boolean;
postgres?: boolean;
pillow?: boolean;
apps: {
name: string;
models: {
name: string;
fields: {
name: string;
type: string;
args: string;
}[];
relationships: {
name: string;
type: string;
to: string;
args: string;
}[];
}[];
}[];
}

switch (command) {
case 'render':
if (args.length < 2) {
Expand All @@ -37,7 +64,7 @@ switch (command) {
}
const input_file = args[1];
const output_file = args[2];
const projectData = JSON.parse(readFileSync(input_file, 'utf8'));
const projectData: JSONProject = JSON.parse(readFileSync(input_file, 'utf8'));

const projectParams = {
channels: projectData.channels || false,
Expand All @@ -56,9 +83,9 @@ switch (command) {

const djangoApp = new DjangoApp(project, appData.name);

const models = appData.models.map((modelData: any) => {
const model = new DjangoModel(djangoApp, modelData.name, false, []);
modelData.fields.forEach((field: any) => {
const models = appData.models.map((modelData) => {
const model = new DjangoModel(djangoApp, modelData['name'], false, []);
modelData.fields.forEach((field) => {
const editable = field.args.indexOf("editable=False") === -1;
console.log("Adding field", field);
const fieldType = FieldTypes[field.type];
Expand All @@ -67,7 +94,7 @@ switch (command) {
}
model.addField(field.name, fieldType, field.args, editable);
})
modelData.relationships.forEach((relationshipData: any) => {
modelData.relationships.forEach((relationshipData) => {
const to: BuiltInModel = BuiltInModelTypes[relationshipData.to];
if (!to) {
throw new Error(`Unsupported relationship to ${relationshipData.to}`);
Expand Down
1 change: 0 additions & 1 deletion lib/djangobuilder-core/src/importer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Exception } from "handlebars"
import {BuiltInModelTypes, DjangoRelationship, ParentModelTypes } from "./api"
import { FieldTypes, RelationshipTypes, DjangoProject, DjangoApp, DjangoModel, DjangoField, DjangoVersion } from "./index"

Expand Down
3 changes: 0 additions & 3 deletions lib/djangobuilder-core/src/smoketest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ console.log(renderer.renderAppFile("models.py", birdsApp));
console.log(renderer.renderAppFile("forms.py", birdsApp));
console.log(renderer.renderAppFile("test_views.py", birdsApp));

const projectTree = renderer.asTree(zooProject);
//console.log("ProjectTree", JSON.stringify(projectTree, null, 2))

const tarballContent = renderer.tarballContent(zooProject);
const outputFile = `${zooProject.name}.tar`;

Expand Down
21 changes: 14 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,31 @@
],
"scripts": {
"dev": "yarn workspace djangobuilder.io dev",
"devio": "yarn workspace djangobuilder.io dev",
"dev4": "yarn workspace djangobuilder4 dev",
"build": "yarn run build_io && yarn build_v4",
"build_development": "yarn run build_io_development && yarn build_v4_development",
"build_io_development": "yarn workspace djangobuilder.io build --mode=development",
"build_v4_development": "yarn workspace djangobuilder.io build:development",
"build_v4_development": "yarn workspace djangobuilder4 build:development",
"build_staging": "yarn run build_io_staging && yarn build_v4_staging",
"build_io_staging": "yarn workspace djangobuilder.io build --mode=staging",
"build_v4_staging": "yarn workspace djangobuilder.io build:staging",
"build_v4_staging": "yarn workspace djangobuilder4 build:staging",
"build_production": "yarn run build_io_production && yarn build_v4_production",
"build_io_production": "yarn workspace djangobuilder.io build --mode=production",
"build_v4_production": "yarn workspace djangobuilder.io build",
"build_v4_production": "yarn workspace djangobuilder4 build",
"build_io": "yarn workspace djangobuilder.io build",
"build_v4": "yarn workspace djangobuilder.io build",
"lint": "yarn workspace djangobuilder.io lint",
"build_v4": "yarn workspace djangobuilder4 build",
"lint": "yarn run lint_core && yarn lint_io && yarn lint_v4",
"lint_core": "yarn workspace @djangobuilder/core lint",
"lint_io": "yarn workspace djangobuilder.io lint",
"lint_v4": "yarn workspace djangobuilder4 lint",
"lint_fix": "yarn run lint_fix_core && yarn lint_fix_io && yarn lint_fix_v4",
"lint_fix_core": "yarn workspace @djangobuilder/core fix-lint",
"lint_fix_io": "yarn workspace djangobuilder.io lint:fix",
"lint_fix_v4": "yarn workspace djangobuilder4 lint:fix",
"test_smoke": "yarn workspace @djangobuilder/core run test_smoke",
"test_core": "yarn workspace @djangobuilder/core run test",
"test_v4": "yarn workspace djangobuilder.io run test:unit",
"test_io": "yarn workspace djangobuilder.io run test:unit",
"test_v4": "yarn workspace djangobuilder4 run test:unit",
"test": "yarn run test_smoke && yarn test_core && yarn test_v4 && yarn test_io",
"ci": "yarn workspace djangobuilder.io run ci",
"cli": "yarn workspace @djangobuilder/core run cli"
Expand Down
12 changes: 0 additions & 12 deletions packages/djangobuilder.io/Makefile

This file was deleted.

14 changes: 14 additions & 0 deletions packages/djangobuilder.io/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pluginVue from 'eslint-plugin-vue'

export default [
// add more generic rulesets here, such as:
// js.configs.recommended,
...pluginVue.configs['flat/essential'],
// ...pluginVue.configs['flat/vue2-recommended'], // Use this if you are using Vue.js 2.x.
{
rules: {
// override/add rules settings here, such as:
"vue/multi-word-component-names": "warn"
}
}
]
37 changes: 5 additions & 32 deletions packages/djangobuilder.io/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "djangobuilder.io",
"version": "2.0.0",
"type": "module",
"private": true,
"bin": {
"django-builder": "bin/django-builder"
Expand All @@ -9,7 +10,8 @@
"dev": "vite --port 8080",
"build": "vite build",
"serve": "vite preview",
"lint": "eslint --ext .js,.ts,.vue --ignore-path .gitignore --fix src",
"lint": "eslint ./src/ ./tests",
"lint:fix": "yarn run lint --fix",
"test:unit": "vitest --run",
"pree2e": "yarn bic",
"preci": "yarn bic"
Expand Down Expand Up @@ -41,8 +43,8 @@
"autoprefixer": "^10.4.8",
"babel-core": "^6.26.3",
"build-if-changed": "^1.5.5",
"eslint": "8",
"eslint-plugin-vue": "8",
"eslint": "^9.17.0",
"eslint-plugin-vue": "^9.32.0",
"eslint-plugin-vuetify": "^1.0.0-beta.6",
"jsdom": "^20.0.1",
"sass": "^1.54.5",
Expand All @@ -61,35 +63,6 @@
"bic": [
"src"
],
"eslintConfig": {
"root": true,
"env": {
"es2021": true
},
"extends": [
"plugin:vue/essential",
"plugin:@typescript-eslint/recommended",
"eslint:recommended"
],
"plugins": [
"vuetify"
],
"rules": {
"vuetify/no-deprecated-classes": "error",
"vuetify/no-legacy-grid": "error",
"no-console": "off",
"no-empty-pattern": "error",
"no-unused-vars": [
"off",
{
"vars": "all",
"args": "after-used",
"argsIgnorePattern": "^_|^unused$",
"varsIgnorePattern": "^_.*$"
}
]
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
Expand Down
6 changes: 3 additions & 3 deletions packages/djangobuilder.io/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function project_data_to_store(project_data) {
}
Object.assign(appData, { [`${i}`]: singleAppData});

app.models.forEach((model, i) => {
app.models.forEach((model) => {
const singleModelData = {
...model,
parents: model.parents || [],
Expand All @@ -57,7 +57,7 @@ function project_data_to_store(project_data) {

Object.assign(modelData, { [`${model.name}`]: singleModelData});

model.fields.forEach((field, i) => {
model.fields.forEach((field) => {
const singleFieldData = {
data: () => {
return {
Expand All @@ -70,7 +70,7 @@ function project_data_to_store(project_data) {
singleModelData.fields[`${field.name}`] = true
})

model.relationships.forEach((relationship, i) => {
model.relationships.forEach((relationship) => {
const singleRelationshipData = {
data: () => {
return {
Expand Down
9 changes: 5 additions & 4 deletions packages/djangobuilder.io/src/components/AppView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</span>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon @click.native="import_dialog = false">
<v-btn icon @click="import_dialog = false">
<v-icon>close</v-icon>
</v-btn>
</v-app-bar>
Expand All @@ -39,8 +39,10 @@
<h4 class="text-h6 font-weight-medium font-italics">
Importing Models - {{num_imported}}/{{imported_models.length}} complete ...
</h4>
<v-progress-linear slot="extension" :value="importing_percent" class="ma-2">
</v-progress-linear>
<template v-slot:extension>
<v-progress-linear :value="importing_percent" class="ma-2">
</v-progress-linear>
</template>
</v-col>
<v-col>
<v-icon class="ma-4" color="primary">
Expand Down Expand Up @@ -535,7 +537,6 @@ export default {
const data = this.$store.getters.projectData(this.id);
const newOpts = {}
Object.values(data.apps).forEach(app => {
const appData = this.appData(app);
Object.keys(app.models).forEach(modelid => {
console.log(modelid)
const modelData = this.modelData(modelid);
Expand Down
2 changes: 1 addition & 1 deletion packages/djangobuilder.io/src/components/Debug.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export default {
name: name,
owner: this.userid,
apps: {}
}).then((_project) => {
}).then(() => {
this.load()
})
Expand Down
7 changes: 3 additions & 4 deletions packages/djangobuilder.io/src/components/DirectoryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
</h2>
<v-card class="ma-2 mr-0" elevation="2">
<v-card-text class="ma-0 pa-0">
<v-treeview dense :items="items" :open.sync="open" :open-all="false" item-key="path" open-on-click return-object
<v-treeview dense :items="items" v-model:open="open" :open-all="false" item-key="path" open-on-click return-object
style="min-height: 800px;">
<template v-slot:prepend="{ item, open }" v-on:click="click">
<template v-slot:prepend="{ item, open }">
<v-icon class="blue--text text--darken-4" v-if="item.folder && open" small>mdi-folder-open</v-icon>
<v-icon class="blue--text text--darken-4" v-else-if="item.folder" small>mdi-folder</v-icon>
<v-icon class="blue--text text--darken-4" v-else small>{{icon(item.name)}}</v-icon>
</template>
<template slot="label" slot-scope="{ item }">
<template v-slot:label="{ item }" >
<div @click="click(item)" :class="active !== undefined && active.path === item.path ? 'red--text text--darken-4 font-weight-bold hidden-md-and-up' : 'hidden-md-and-up'">
{{ item.name }}
</div>
Expand Down Expand Up @@ -95,7 +95,6 @@
</template>

<script>
import store from "../store";
import { Renderer as DBCoreRenderer } from "@djangobuilder/core"
import { DjangoProjectFileResource } from "@djangobuilder/core/src/rendering"
const coreRenderer = new DBCoreRenderer();
Expand Down
Loading

0 comments on commit 64095f7

Please sign in to comment.