diff --git a/README.md b/README.md
index d64ae80..c5a6484 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,6 @@
```
novas create my-app
cd my-app
-novas build
novas dev
```
- After running novas dev
, open http://localhost:3000 to see your app.
@@ -29,17 +28,25 @@ novas dev
- Install NOVAS
```
-deno install --allow-net --allow-read --allow-write --unstable https://deno.land/x/novas/cli.ts
+deno install --allow-net --allow-read --allow-write --allow-run --unstable https://deno.land/x/novas/cli.ts
```
About Permissions
- --allow-net: Required for the dev server.
- --allow-read: Allows NOVAS to compile svelte files.
- --allow-write: Allows NOVAS to write to files it creates during the
novas build
process
+ - --allow-run: Allows NOVAS to run shell command.
- --unstable: Allows the use of Deno's standard modules which might not be stable yet.
Read more about permissions or stability here
+or simply,
+
+```
+deno install -A https://deno.land/x/novas/cli.ts
+```
+
+
## ⭐ How to use NOVAS
@@ -48,19 +55,23 @@ Read more about {
+ const buildexists=await existsSync(buildfn);
+ await ensureFile(buildfn);
+
+ const srcstat=await Deno.fstatSync( Deno.openSync(srcfn, { read: true }).rid);
+ const buildstat=await Deno.fstatSync( Deno.openSync(buildfn, { read: true }).rid);
+ const srcmtime=srcstat?.mtime || 0;
+ const buildmtime=buildstat?.mtime || -1;
+
+ return (!buildexists || srcmtime>buildmtime);
+}
// Function to run when given build command
export const BuildProject = async (flag: string, cwd = Deno.cwd(), path = '/src/App.svelte') => { // C:\\Users\\Tanner\\Documents\\GitHub\\NOVAS2\\tests\\src\\App.svelte
const sveltePath = "https://cdn.skypack.dev/svelte@3.44.1";
@@ -19,40 +30,42 @@ export const BuildProject = async (flag: string, cwd = Deno.cwd(), path = '/src/
await ensureFile("./build/index.js");
Deno.writeFile("./build/index.js", encoder.encode(boilerplate.indexJs));
-
+
const buildImports = async (filePath: string) => {
+ let buildfn=join("./build", filePath.replace(cwd, ""));
+ buildfn += filePath.endsWith(".svelte") ? '.js':'';
+
filePath.endsWith(".svelte") ? await handleSvelte() : handleOther();
async function handleSvelte() {
const { js, ast } = await compiler(filePath);
- const data = encoder.encode(js);
-
- await ensureFile(join("./build", filePath.replace(cwd, "")) + ".js");
- await Deno.writeFile(
- join("./build", filePath.replace(cwd, "")) + ".js",
- data,
- );
-
+ if (await updateNeeded(filePath,buildfn)) {
+ console.log('updating',filePath);
+ const data = encoder.encode(js);
+ await Deno.writeFile(buildfn,data);
+ }
const nestedImports = ast.instance?.content?.body?.filter((
script: { type: string; source: { value: string } },
) => script.type === "ImportDeclaration");
if (!nestedImports) return;
- for (const nested of nestedImports) {
+ for await (const nested of nestedImports) {
if (memoized[nested.source.value] === true) continue;
memoized[nested.source.value] = true;
- buildImports(join(cwd, nested.source.value.replace(".", "src/")));
+ await buildImports(join(cwd, nested.source.value.replace(".", "src/")));
}
}
async function handleOther() {
try {
- const currentFile = await Deno.readTextFile(filePath);
- const denofiedFile = await denofy(currentFile, sveltePath);
- const data = encoder.encode(denofiedFile);
- await ensureFile("./build" + filePath.replace(cwd, ''));
- await Deno.writeFile("./build" + filePath.replace(cwd, ''), data);
+ if (await updateNeeded(filePath,buildfn)) {
+ const currentFile = await Deno.readTextFile(filePath);
+ const denofiedFile = await denofy(currentFile, sveltePath);
+ const data = encoder.encode(denofiedFile);
+ await Deno.writeFile(buildfn, data);
+ }
}
- catch {
+ catch(e) {
+ console.log(e);
return;
}
}
diff --git a/commands/create.ts b/commands/create.ts
index 456612b..c1e04ee 100644
--- a/commands/create.ts
+++ b/commands/create.ts
@@ -4,6 +4,7 @@ import {
indexHTML,
mainJs,
svelteAppComponent,
+ svelteComponent,
vscodeDenoSettings,
defaultConfigFile,
} from "../templates/templates.ts";
@@ -26,15 +27,21 @@ export async function CreateProject(name: string, path: string, flag: string): P
await Deno.mkdir(join(appDir, ".vscode"));
const indexHtmlFile = await Deno.create(join(`${path}/${name}/public`, "index.html"));
+ const indexBundleHtmlFile = await Deno.create(join(`${path}/${name}/public`, "index.bundle.html"));
const settings = await Deno.create(join(`${path}/${name}/.vscode`, "settings.json"));
const defaultConfig = await Deno.create(join(appDir, "compileOptions.json"));
const srcFile = await Deno.create(join(`${appDir}/src`, "App.svelte"));
+ const componentFile = await Deno.create(join(`${appDir}/src`, "component.svelte"));
const mainJsFile = await Deno.create(join(`${appDir}/src`, "index.js"));
indexHtmlFile.write(encoder.encode(indexHTML));
+ indexBundleHtmlFile.write(encoder.encode(
+ indexHTML.replace('