nanosts
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -14,2 +14,3 @@ import { Command } from "@oclif/core"; | ||
scriptFolders: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>; | ||
lazy: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>; | ||
}; | ||
@@ -16,0 +17,0 @@ run(): Promise<void>; |
@@ -41,3 +41,4 @@ "use strict"; | ||
const scriptFolders = (((_a = flags.scriptFolders) === null || _a === void 0 ? void 0 : _a.toString()) || "").split(","); | ||
return { name, author, version, type, scriptFolders }; | ||
const lazy = flags.lazy; | ||
return { name, author, version, type, scriptFolders, lazy }; | ||
} | ||
@@ -76,3 +77,9 @@ else { | ||
}]))["script folders"]; | ||
return { name, author, version, type, scriptFolders }; | ||
const { lazy } = await inquirer.prompt([{ | ||
name: 'lazy', | ||
message: 'enable lazy loading', | ||
type: 'confirm', | ||
default: true | ||
}]); | ||
return { name, author, version, type, scriptFolders, lazy }; | ||
} | ||
@@ -91,2 +98,3 @@ } | ||
scriptFolders: core_1.Flags.string({ description: "Script folders of the project", char: "s" }), | ||
lazy: core_1.Flags.boolean({ description: "Enable lazy compiling which auto-generates bridge scripts for the dist folder", char: "l", default: true }), | ||
}; |
@@ -10,2 +10,3 @@ import { Command } from "@oclif/core"; | ||
scriptFolders: ScriptFolder[]; | ||
lazy: boolean; | ||
} | ||
@@ -12,0 +13,0 @@ export declare class ProjectGenerator { |
@@ -45,2 +45,19 @@ "use strict"; | ||
} | ||
if (this.data.lazy) { | ||
subscriber.next("Lazy scripts"); | ||
const createLazyScript = async (name) => { | ||
await fs.promises.mkdir(p.join(path, name), { recursive: true }); | ||
const filePath = p.join(path, name, "Index.lua"); | ||
await fs.promises.writeFile(filePath, `Package.Require(\"../dist/${name}/Index.lua\")`); | ||
}; | ||
if (this.data.scriptFolders.includes("server")) { | ||
await createLazyScript("Server"); | ||
} | ||
if (this.data.scriptFolders.includes("shared")) { | ||
await createLazyScript("Shared"); | ||
} | ||
if (this.data.scriptFolders.includes("client")) { | ||
await createLazyScript("Client"); | ||
} | ||
} | ||
subscriber.complete(); | ||
@@ -113,7 +130,6 @@ })(); | ||
scripts: { | ||
build: "tstl && shx cp Package.toml dist/Package.toml", | ||
build: `tstl${(this.data.lazy ? '' : ' && shx cp Package.toml dist/Package.toml')}`, | ||
"update-types": "nanosts generate -o=./@types", | ||
}, | ||
devDependencies: { | ||
"shx": "^0.3.4", | ||
"typescript": "^4.6.4", | ||
@@ -124,2 +140,5 @@ "typescript-to-lua": "^1.4.4", | ||
}; | ||
if (!this.data.lazy) { | ||
packageJson.devDependencies["shx"] = "^0.3.4"; | ||
} | ||
await fs.promises.writeFile(p.join(path, "package.json"), JSON.stringify(packageJson, null, 2)); | ||
@@ -154,3 +173,3 @@ } | ||
types: [ | ||
"typescript-to-lua/language-extensions" | ||
"@typescript-to-lua/language-extensions" | ||
], | ||
@@ -165,2 +184,3 @@ typeRoots: [ | ||
luaLibImport: "inline", | ||
noImplicitSelf: true, | ||
luaPlugins: [ | ||
@@ -167,0 +187,0 @@ { name: "./transpilers/imports.ts" } |
@@ -1,1 +0,1 @@ | ||
{"version":"1.0.2","commands":{"generate":{"id":"generate","description":"Generates Nanos TypeScript declarations from the Docs JSON API","strict":true,"pluginName":"nanosts","pluginAlias":"nanosts","pluginType":"core","aliases":[],"flags":{"bleeding":{"name":"bleeding","type":"boolean","char":"b","description":"Use the bleeding edge version instead of the stable version","allowNo":false},"skip":{"name":"skip","type":"boolean","char":"s","description":"Whether to skip existing files or not","allowNo":false},"output":{"name":"output","type":"option","char":"o","description":"Output directory for the generated files","required":true,"multiple":false}},"args":[]},"project":{"id":"project","description":"Creates a new Nanos TypeScript project","strict":true,"pluginName":"nanosts","pluginAlias":"nanosts","pluginType":"core","aliases":[],"flags":{"author":{"name":"author","type":"option","char":"a","description":"Author of the project","multiple":false},"version":{"name":"version","type":"option","char":"v","description":"Version of the project","multiple":false,"default":"1.0.0"},"type":{"name":"type","type":"option","char":"t","description":"Type of the project","multiple":false},"scriptFolders":{"name":"scriptFolders","type":"option","char":"s","description":"Script folders of the project","multiple":false}},"args":[{"name":"name","description":"Name of the project","required":true}]}}} | ||
{"version":"1.1.0","commands":{"generate":{"id":"generate","description":"Generates Nanos TypeScript declarations from the Docs JSON API","strict":true,"pluginName":"nanosts","pluginAlias":"nanosts","pluginType":"core","aliases":[],"flags":{"bleeding":{"name":"bleeding","type":"boolean","char":"b","description":"Use the bleeding edge version instead of the stable version","allowNo":false},"skip":{"name":"skip","type":"boolean","char":"s","description":"Whether to skip existing files or not","allowNo":false},"output":{"name":"output","type":"option","char":"o","description":"Output directory for the generated files","required":true,"multiple":false}},"args":[]},"project":{"id":"project","description":"Creates a new Nanos TypeScript project","strict":true,"pluginName":"nanosts","pluginAlias":"nanosts","pluginType":"core","aliases":[],"flags":{"author":{"name":"author","type":"option","char":"a","description":"Author of the project","multiple":false},"version":{"name":"version","type":"option","char":"v","description":"Version of the project","multiple":false,"default":"1.0.0"},"type":{"name":"type","type":"option","char":"t","description":"Type of the project","multiple":false},"scriptFolders":{"name":"scriptFolders","type":"option","char":"s","description":"Script folders of the project","multiple":false},"lazy":{"name":"lazy","type":"boolean","char":"l","description":"Enable lazy compiling which auto-generates bridge scripts for the dist folder","allowNo":false}},"args":[{"name":"name","description":"Name of the project","required":true}]}}} |
{ | ||
"name": "nanosts", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "NanosTS CLI helps you to get started with nanos world TypeScript", | ||
@@ -5,0 +5,0 @@ "author": "DasDarki @DasDarki", |
@@ -20,3 +20,3 @@ NanosTS CLI | ||
$ nanosts (--version) | ||
nanosts/1.0.2 win32-x64 node-v16.15.0 | ||
nanosts/1.1.0 win32-x64 node-v16.15.0 | ||
$ nanosts --help [COMMAND] | ||
@@ -64,3 +64,3 @@ USAGE | ||
_See code: [dist/commands/generate.ts](https://github.com/NanosWorldTS/nanos-typescript-cli/blob/v1.0.2/dist/commands/generate.ts)_ | ||
_See code: [dist/commands/generate.ts](https://github.com/NanosWorldTS/nanos-typescript-cli/blob/v1.1.0/dist/commands/generate.ts)_ | ||
@@ -93,3 +93,3 @@ ## `nanosts help [COMMAND]` | ||
USAGE | ||
$ nanosts project [NAME] [-a <value>] [-v <value>] [-t <value>] [-s <value>] | ||
$ nanosts project [NAME] [-a <value>] [-v <value>] [-t <value>] [-s <value>] [-l] | ||
@@ -101,2 +101,3 @@ ARGUMENTS | ||
-a, --author=<value> Author of the project | ||
-l, --lazy Enable lazy compiling which auto-generates bridge scripts for the dist folder | ||
-s, --scriptFolders=<value> Script folders of the project | ||
@@ -110,3 +111,3 @@ -t, --type=<value> Type of the project | ||
_See code: [dist/commands/project.ts](https://github.com/NanosWorldTS/nanos-typescript-cli/blob/v1.0.2/dist/commands/project.ts)_ | ||
_See code: [dist/commands/project.ts](https://github.com/NanosWorldTS/nanos-typescript-cli/blob/v1.1.0/dist/commands/project.ts)_ | ||
<!-- commandsstop --> | ||
@@ -113,0 +114,0 @@ * [`nanosts generate`](#nanosts-generate) |
98343
1239
306