Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test dependencies #6

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
18 changes: 12 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
//vscode import settings for default formatter (typescript && js)

// using official denoland extension
{
"deno.enable": true,
"deno.lint": true,
"deno.unstable": true,
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
"deno.unstable": false,
"deno.codeLens.test": true, // default : `true`
"deno.codeLens.testArgs": ["--allow-all", "--unstable"], // default : `[ "--allow-all" ]`
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
},
"[javascript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
"editor.defaultFormatter": "denoland.vscode-deno",
"editor.formatOnSave": true,
"editor.formatOnPaste": false,
"deno.suggest.imports.hosts": {
"https://deno.land": true
}
}
83 changes: 49 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,30 @@

## Overview

- Vue is an approachable, incrementally adoptable JavaScript framework with an exciting ecosystem. Deno is a new runtime environment for JavaScript, built to address the shortcomings of node.js. We wanted to create a tool that let developers easily set up Vue applications in a Deno runtime environment. Meet vno!
- Vue is an approachable, incrementally adoptable JavaScript framework with an
exciting ecosystem. Deno is a new runtime environment for JavaScript, built to
address the shortcomings of node.js. We wanted to create a tool that let
developers easily set up Vue applications in a Deno runtime environment. Meet
vno!

## How to use vno

- You can use the vno Command Line Interface to quickly create a new Vue project in a Deno runtime
- You can use the vno Command Line Interface to quickly create a new Vue project
in a Deno runtime
- OR you can use the vno build method to compile an existing Vue file structure
into a Deno-legible .js file

### vno installation

- vno requires the use of Deno version 1.10 or above
- MacOS:
- MacOS:
- Run the following command in your terminal to install vno on your machine.

```bash
deno install --allow-net --unstable https://deno.land/x/vno/install/vno.ts
```

- WSL/Linux:
- WSL/Linux:
- Open `/home/<USERNAME>/bashrc` with your editor of choice.
- Add `export PATH="/home/<USERNAME>/.deno/bin:$PATH` to the end of the file.
- Run the following command in your terminal to install vno on your machine.
Expand All @@ -61,10 +66,11 @@ sudo deno install --allow-net --unstable https://deno.land/x/vno/install/vno.ts
'vno' is the default name.
- If you have not already added Deno bin into your path, you will need to do so.

- MacOS: Copy the export path your terminal returns and paste it into your terminal
- WSL/Linux: Replace `root` with your username and paste it into your terminal:
`export PATH="/home/<USERNAME>/.deno/bin:$PATH"`
![install gif](https://media.giphy.com/media/LVokebNuReGJuwU13R/giphy.gif)
- MacOS: Copy the export path your terminal returns and paste it into your
terminal
- WSL/Linux: Replace `root` with your username and paste it into your
terminal: `export PATH="/home/<USERNAME>/.deno/bin:$PATH"`
![install gif](https://media.giphy.com/media/LVokebNuReGJuwU13R/giphy.gif)

### a quick word about permissions

Expand All @@ -76,8 +82,8 @@ sudo deno install --allow-net --unstable https://deno.land/x/vno/install/vno.ts
`--allow-write`
- If you decide not to flag permissions at installation, you will be prompted in
the terminal after executing a command.
- If you would like to avoid writing out the permissions altogether, you
can also use the `-A` or `--allow-all` tag
- If you would like to avoid writing out the permissions altogether, you can
also use the `-A` or `--allow-all` tag

### vno config

Expand All @@ -86,21 +92,23 @@ sudo deno install --allow-net --unstable https://deno.land/x/vno/install/vno.ts

```ts
interface Config {
entry: string;
//entry is the path to root component's directory : i.e. './client/'
root: string;
//root is the filename of your root component : i.e. 'App'
vue?: 2 | 3;
//vue is the number 2 or 3 : 2 = vue v2.6.12 (default); 3 = vue v3.0.5
options?: {
port?: number;
//preferred port for the dev server : defaults to `3000`
title?: string;
//title of your project
hostname?: string;
//preferred host : defaults to `0.0.0.0`
};
}
entry: string;
//entry is the path to root component's directory : i.e. './client/'
root: string;
//root is the filename of your root component : i.e. 'App'
vue?: 2 | 3;
//vue is the number 2 or 3 : 2 = vue v2.6.12 (default); 3 = vue v3.0.5
options?: {
port?: number;
//preferred port for the dev server : defaults to `3000`
reloadPort?: number;
// preferred port for dev server reload : defaults to `8080`
title?: string;
//title of your project
hostname?: string;
//preferred host : defaults to `0.0.0.0`
};
}
```

## CLI
Expand All @@ -109,8 +117,11 @@ interface Config {

- Project name will become the directory that holds your project (you must CD
into project directory after running the `vno create` command).
- If the project name argument is omitted, then the project will be created in the current working directory.
- Using `vno create` will give an option to build out a universal or single page application. Choosing 'SPA' will give you the option of choosing to add Vue Router, as well as choosing between Vue 2 or Vue 3 syntax.
- If the project name argument is omitted, then the project will be created in
the current working directory.
- Using `vno create` will give an option to build out a universal or single page
application. Choosing 'SPA' will give you the option of choosing to add Vue
Router, as well as choosing between Vue 2 or Vue 3 syntax.

```bash
vno create [project name]
Expand Down Expand Up @@ -141,15 +152,19 @@ deno run --allow-read --allow-write --allow-net --unstable https://deno.land/x/v

![vno build](https://i.ibb.co/jgRFXvc/vno-build.gif)

**Scoped styling for CSS is currently not supported, but will be added to future builds**
**Scoped styling for CSS is currently not supported, but will be added to future
builds**

### run a build on a project AND create a server configured for SSR

- To invoke the build method and dynamically create bundled JS and CSS files, along with a server.ts for server side rendering your application, type the following into the terminal:
- To invoke the build method and dynamically create bundled JS and CSS files,
along with a server.ts for server side rendering your application, type the
following into the terminal:

```bash
vno build --ssr
```

_OR_

```bash
Expand All @@ -162,7 +177,9 @@ deno run --allow-read --allow-write --allow-net --unstable https://deno.land/x/v

- Running the dev server dynamically runs a new build and runs the application
on a module hosted server.
- Native `vno run dev` command automatically enables live reload. Using Live Reload injects a WebSocket connection to build.js. Remove it with: `vno run build`
- Native `vno run dev` command automatically enables live reload. Using Live
Reload injects a WebSocket connection to build.js. Remove it with:
`vno run build`
- Invoke the dev server using the following commands:

```bash
Expand All @@ -177,8 +194,6 @@ deno run --allow-read --allow-write --allow-net --unstable https://deno.land/x/v

![vno run dev & live reload](https://i.ibb.co/c15qK5J/final-live-gif.gif)



# vno as an API

### initializing your application with the api
Expand All @@ -188,7 +203,7 @@ deno run --allow-read --allow-write --allow-net --unstable https://deno.land/x/v
needed The API will search for the config and apply it to your application

```ts
import { Factory } from 'https://deno.land/x/vno/dist/mod.ts';
import { Factory } from "https://deno.land/x/vno/dist/mod.ts";

const vno = new Factory();
await vno.build();
Expand Down Expand Up @@ -221,7 +236,7 @@ await vno.build();
property on the Factory class.

```ts
vno.storage.get('App');
vno.storage.get("App");
```

The argument accepted by the get method for storage is the component filename
8 changes: 4 additions & 4 deletions core/__tests__/benchmark.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { //import bench and runBenchmarks from deno URL
import { //import bench and runBenchmarks from deno URL
bench,
runBenchmarks,
} from "https://deno.land/[email protected]/testing/bench.ts";
} from "./test_deps.ts";

import Factory from "../factory/Factory.ts";

//***MEASURES HOW LONG BUILD METHOD TAKES TO COMPLETE***//
bench({ //bench registers the code below to the benchmark
name: "complete vno runtime benchmark", //name of benchmark test
runs: 1, //runs one time
func(x: { start: () => void; stop: () => void }): void { //start and stop function that takes no args and doesn't return anything
func(x: { start: () => void; stop: () => void }): void { //start and stop function that takes no args and doesn't return anything
x.start();
const vnoTest = Factory.create(); //TS class to build VNO app. Factory.create() creates everything
const vnoTest = Factory.create(); //TS class to build VNO app. Factory.create() creates everything
vnoTest.build(); //runs build on everything from ^^
x.stop(); //stops funcX.
},
Expand Down
24 changes: 12 additions & 12 deletions core/__tests__/test_commands.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { assertEquals, fs } from "../utils/deps.ts";
import { assertEquals, fs } from "./test_deps.ts";
import { yellow } from "../cli/fns.ts";

Deno.test({ //TESTS CREATE COMMANDS
Deno.test({ //TESTS CREATE COMMANDS
name: "\n\ntesting success of create command\n",
fn(): void {
const args = [ //array of tests
const args = [ //array of tests
"create",
"cli-test",
"yes",
Expand All @@ -17,30 +17,30 @@ Deno.test({ //TESTS CREATE COMMANDS
];

yellow("\n>> project directory was created"); //prints to terminal in yellow
assertEquals( //tests if create command creates a new proj called cli-test as directory
assertEquals( //tests if create command creates a new proj called cli-test as directory
fs.existsSync("./cli-test"), //used to synchronously check if file already exists in given path; RETURNS BOOLEAN
true, //EXPECTED BOOLEAN VALUE
);

yellow("\n>> root component file was created");//prints to terminal in yellow
assertEquals(//tests if create command creates a new proj called cli-test as directory and TestApp.vue as root file
yellow("\n>> root component file was created"); //prints to terminal in yellow
assertEquals( //tests if create command creates a new proj called cli-test as directory and TestApp.vue as root file
fs.existsSync("./cli-test/TestApp.vue"),
true, //EXPECTED BOOLEAN VALUE
);

yellow("\n>> config file was created");//prints to terminal in yellow
assertEquals(//tests if create command creates vno.config.json file
yellow("\n>> config file was created"); //prints to terminal in yellow
assertEquals( //tests if create command creates vno.config.json file
fs.existsSync("./cli-test/vno.config.json"),
true, //EXPECTED BOOLEAN VALUE
);

yellow("\n>> router file (cli-test/router/index.js) was created");//prints to terminal in yellow
assertEquals(//tests if create command creates vno.config.json file
yellow("\n>> router file (cli-test/router/index.js) was created"); //prints to terminal in yellow
assertEquals( //tests if create command creates vno.config.json file
fs.existsSync("./cli-test/router/index.js"),
true, //EXPECTED BOOLEAN VALUE
);

const json = Deno.readTextFileSync("./cli-test/vno.config.json");//prints to terminal in yellow
const json = Deno.readTextFileSync("./cli-test/vno.config.json"); //prints to terminal in yellow
const res = JSON.parse(json);

yellow("\n>> project root labeled in vno.config");
Expand Down Expand Up @@ -92,7 +92,7 @@ Deno.test({ //TESTS IF BUILD COMMANDS WORKED

yellow("\n>> style.css file compiled");
assertEquals(
fs.existsSync("./cli-test/vno-build/style.css"), // will compile all css into single style.css file
fs.existsSync("./cli-test/vno-build/style.css"), // will compile all css into single style.css file
true, //EXPECTED BOOLEAN VALUE
);
},
Expand Down
13 changes: 13 additions & 0 deletions core/__tests__/test_deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// deno testing library
export { //export bench and runBenchmarks from deno URL
bench,
runBenchmarks,
} from "https://deno.land/[email protected]/testing/bench.ts";
export {
assertEquals,
assertNotEquals,
} from "https://deno.land/[email protected]/testing/asserts.ts"; // testing library

// deno standard
export * as fs from "https://deno.land/[email protected]/fs/mod.ts";
export * as path from "https://deno.land/[email protected]/path/mod.ts";
9 changes: 4 additions & 5 deletions core/__tests__/test_lib.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Component, Config, Vue } from "../dts/factory.d.ts";
import { configReader } from "../lib/config_reader.ts";
import { vueLogger } from "../lib/vue_logger.ts";
import { assertEquals, assertNotEquals, path } from "../utils/deps.ts";
import { assertEquals, assertNotEquals, path } from "./test_deps.ts";

// configReader tests:
// Tests if the configReader can read vno.config.json properly
Expand All @@ -22,7 +22,7 @@ Deno.test({
);

const config: Config | unknown = await configReader(); //checks if Config or Unknown; if unknown invoke configReader()
assertNotEquals((config as Config), undefined); // checks if config is undefined
assertNotEquals(config as Config, undefined); // checks if config is undefined
assertEquals((config as Config).vue, 3); //tests config as Config with stringify keys on LINE 15-19 and checks value
assertEquals((config as Config).entry, "../../example/test_demo/"); // checks entry
assertEquals((config as Config).root, "App"); // checks root is equal to "App"
Expand All @@ -39,7 +39,6 @@ Deno.test({
// vueLogger tests:
const component = <Component> { label: "TestRoot", name: "test-root" };


Deno.test({ //test checks if vueLogger returns object with valid props
name: "vueLogger returns object with valid props for Vue2",

Expand All @@ -50,7 +49,7 @@ Deno.test({ //test checks if vueLogger returns object with valid props
"label",
);

assertNotEquals((V2 as Vue.State), undefined);
assertNotEquals(V2 as Vue.State, undefined);

const dep = "import Vue from ";
assertEquals((V2 as Vue.State).dep, dep); // checks to see if dep matches
Expand All @@ -70,7 +69,7 @@ Deno.test({ //test checks if vueLogger returns object with valid props for VUE3
"label",
);

assertNotEquals((V3 as Vue.State), undefined);
assertNotEquals(V3 as Vue.State, undefined);

const dep = "import * as Vue from "; // checks to see if dep matches
assertEquals((V3 as Vue.State).dep, dep);
Expand Down
8 changes: 4 additions & 4 deletions core/__tests__/test_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as parse from "../lib/parser.ts";
import Component from "../factory/Component.ts";
import Storage from "../factory/Storage.ts";
import Queue from "../factory/Queue.ts";
import { assertEquals, assertNotEquals, path } from "../utils/deps.ts";
import { assertEquals, assertNotEquals, path } from "./test_deps.ts";
import { patterns } from "../utils/constants.ts";
import { yellow } from "../cli/fns.ts";

Expand Down Expand Up @@ -54,9 +54,9 @@ Deno.test({ //tests to check if script was properly added
assertEquals(typeof testRoot.script, "string"); //tests to check if value is 'string'

yellow(">> parse.script removes comments\n");
assertEquals(
assertEquals(
testRoot.script?.match("// this is a javascript comment\n"), // checks if parser removes comment
null,//EXPECTS NULL
null, //EXPECTS NULL
);

yellow(">> parse.script does not remove URLs\n");
Expand All @@ -68,7 +68,7 @@ Deno.test({ //tests to check if script was properly added
yellow(">> testRoot has a child reference to its dependant\n");
assertEquals(
testRoot.dependants?.head,
testChild,
testChild,
);
},
});
Expand Down
2 changes: 1 addition & 1 deletion core/__tests__/test_utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "../utils/deps.ts";
import { assertEquals } from "./test_deps.ts";
import { patterns } from "../utils/constants.ts";
import { indexOfRegExp, sliceAndTrim } from "../utils/utils.ts";

Expand Down
Loading