-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
3,699 additions
and
4,209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env node | ||
|
||
require = require('esm')(module /*, options*/); | ||
require('../packages/djangobuilder.io/src/cli').cli(process.argv); | ||
require('../lib/djangobuilder-core/src/cli').cli(process.argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env node | ||
import DjangoProject, { DjangoApp, DjangoModel, DjangoField, DjangoRelationship } from './api'; | ||
import Renderer from './rendering'; | ||
import { DjangoVersion } from './types'; | ||
|
||
const args = process.argv.slice(2); | ||
|
||
console.log("ARGS", args); | ||
|
||
if (args.length === 0) { | ||
console.error('No arguments provided.'); | ||
process.exit(1); | ||
} | ||
|
||
const command = args[0]; | ||
|
||
switch (command) { | ||
case 'render': | ||
if (args.length < 2) { | ||
console.error('No template provided for rendering.'); | ||
process.exit(1); | ||
} | ||
if (args.length < 3) { | ||
console.error('No outputfile provided.'); | ||
process.exit(1); | ||
} | ||
const input_file = args[1]; | ||
const output_file = args[2]; | ||
const projectData = JSON.parse(require('fs').readFileSync(input_file, 'utf8')); | ||
|
||
const projectParams = { | ||
channels: projectData.channels || false, | ||
htmx: projectData.htmx || false, | ||
postgres: projectData.postgres || false, | ||
pillow: projectData.pillow || false, | ||
} | ||
const project = new DjangoProject( | ||
projectData.name, | ||
projectData.description, | ||
projectData.version || DjangoVersion.DJANGO4, | ||
projectParams, | ||
); | ||
|
||
for (const appData of projectData["apps"]) { | ||
|
||
const djangoApp = new DjangoApp(project, appData.name); | ||
|
||
const models = appData.models.map((modelData: any) => { | ||
const model = new DjangoModel(djangoApp, modelData.name, false, []); | ||
model.fields.forEach((field: any) => { | ||
model.addField(field.name, field.type, field.options); | ||
}) | ||
return model; | ||
|
||
}); | ||
|
||
project.addApp(appData.name, models); | ||
} | ||
console.log("Created Project", project); | ||
const renderer = new Renderer(); | ||
const tarballContent = renderer.tarballContent(project); | ||
// write to file | ||
require('fs').writeFileSync(output_file, tarballContent); | ||
console.log(`Rendered project to ${output_file}`); | ||
break; | ||
default: | ||
console.error(`Unknown command: ${command}`); | ||
process.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
{ | ||
"extends": "@tsconfig/node16/tsconfig.json", | ||
"compilerOptions": {"outDir": "dist"}, | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"moduleResolution": "node", | ||
"outDir": "dist", | ||
"skipLibCheck": true, | ||
}, | ||
"include": ["src"], | ||
"exclude": ["node_modules"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.