Skip to content

Commit b56e3d7

Browse files
committed
Empty template implemented
1 parent 51e04af commit b56e3d7

File tree

2 files changed

+40
-26
lines changed

2 files changed

+40
-26
lines changed

lib/modules/jsapi.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,14 @@ class CoreCoder {
200200
ctx, function, thisObject, argumentCount, arguments, exception);
201201
return nullptr;
202202
}
203-
203+
static String getProjectFolder(String moduleFolderName, String folderName) {
204+
var result = PluginsManager.projectsPath +
205+
moduleFolderName +
206+
Platform.pathSeparator +
207+
folderName +
208+
Platform.pathSeparator;
209+
return result;
210+
}
204211
static Pointer jsGetProjectFolder(
205212
Pointer ctx,
206213
Pointer function,

lib/modules/module_core.dart

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import 'dart:io' show File;
2+
import 'package:corecoder_develop/modules/jsapi.dart';
23
import 'package:corecoder_develop/util/modules_manager.dart';
34
import 'package:flutter/material.dart';
5+
6+
import '../main.dart';
47
class CoreModule extends Module { //TODO doesnt work
58

69
@override
@@ -13,39 +16,43 @@ class CoreModule extends Module { //TODO doesnt work
1316
null,
1417
"com.corecoder.coremodule");
1518

16-
Future<void> createSolution(String filepath, Map<String, dynamic> args, {String? bpPath, String? rpPath}) async {
17-
/// ---------------------------
18-
/// Create .ccsln.json file
19-
/// ---------------------------
20-
var obj = {
21-
"cc_version": "0.0.1",
22-
"name": "package name",
23-
"author": "youre name",
24-
"description": "package description",
25-
"identifier": identifier,
26-
// must be unique to every module
27-
"folders": {
28-
},
29-
"run_config": [
30-
]
31-
};
32-
33-
// Write the file asynchronously
34-
var slnFile = File(filepath);
35-
await slnFile.create(recursive: true);
36-
await slnFile.writeAsString(ModulesManager.encoder.convert(obj));
37-
}
38-
3919
@override
4020
void onInitialized(ModulesManager modulesManager, BuildContext buildContext) async {
4121
super.onInitialized(modulesManager, buildContext);
4222
var template = Template(
4323
"Empty", //title
44-
"Empty project", //desc
24+
"Empty project with no workspace plugins or files", //desc
4525
"",
46-
{},
26+
{
27+
"Project Name" : "String",
28+
"Author" : "String",
29+
},
4730
(Map<String, dynamic> args) async {
4831
//do absolutely nothing because this is empty
32+
/// ---------------------------
33+
/// Create .ccsln.json file
34+
/// ---------------------------
35+
var obj = {
36+
"cc_version": CoreCoderApp.version,
37+
"name": args["Project Name"],
38+
"author": args["Author"],
39+
"description": "",
40+
"identifier": identifier,
41+
// must be unique to every module
42+
"folders": {
43+
},
44+
"run_config": []
45+
};
46+
obj["folders"]["Workspace"] = ".";
47+
48+
49+
// Write the file asynchronously
50+
var slnFilePath = CoreCoder.getProjectFolder("core", args["Project Name"]) + "solution.ccsln.json";
51+
var slnFile = File(slnFilePath);
52+
await slnFile.create(recursive: true);
53+
await slnFile.writeAsString(ModulesManager.encoder.convert(obj));
54+
// Return the filepath so it loads the project automatically
55+
return slnFilePath;
4956
},
5057
icon, "com.corecoder.empty");
5158

0 commit comments

Comments
 (0)