diff --git a/.storybook/main.js b/.storybook/main.js
index 9fa12a9..cbe87f7 100644
--- a/.storybook/main.js
+++ b/.storybook/main.js
@@ -2,7 +2,7 @@ const path = require("path");
const preprocess = require("svelte-preprocess");
module.exports = {
- // core: { builder: "storybook-builder-vite" },
+ core: { builder: "storybook-builder-vite" },
staticDirs: ["../static", "../pictures"],
stories: [
"../src/**/*.stories.mdx",
@@ -18,10 +18,14 @@ module.exports = {
preprocess: preprocess(),
},
async viteFinal(config, { configType }) {
+
+ if(!config.resolve.alias) config.resolve.alias = {};
// customize the Vite config here
config.resolve.alias.$lib = path.resolve(__dirname, "../src/lib/");
config.resolve.alias.$app = path.resolve(__dirname, "../fake/app/");
+ config.resolve.dedupe = ["@storybook/client-api"];
+
// return the customized config
return config;
},
diff --git a/_templates/generator/help/index.ejs.t b/_templates/generator/help/index.ejs.t
new file mode 100644
index 0000000..90a29af
--- /dev/null
+++ b/_templates/generator/help/index.ejs.t
@@ -0,0 +1,5 @@
+---
+message: |
+ hygen {bold generator new} --name [NAME] --action [ACTION]
+ hygen {bold generator with-prompt} --name [NAME] --action [ACTION]
+---
\ No newline at end of file
diff --git a/_templates/generator/new/hello.ejs.t b/_templates/generator/new/hello.ejs.t
new file mode 100644
index 0000000..5680d96
--- /dev/null
+++ b/_templates/generator/new/hello.ejs.t
@@ -0,0 +1,18 @@
+---
+to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs.t
+---
+---
+to: app/hello.js
+---
+const hello = ```
+Hello!
+This is your first hygen template.
+
+Learn what it can do here:
+
+https://github.com/jondot/hygen
+```
+
+console.log(hello)
+
+
diff --git a/_templates/generator/with-prompt/hello.ejs.t b/_templates/generator/with-prompt/hello.ejs.t
new file mode 100644
index 0000000..ba6abc5
--- /dev/null
+++ b/_templates/generator/with-prompt/hello.ejs.t
@@ -0,0 +1,18 @@
+---
+to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs.t
+---
+---
+to: app/hello.js
+---
+const hello = ```
+Hello!
+This is your first prompt based hygen template.
+
+Learn what it can do here:
+
+https://github.com/jondot/hygen
+```
+
+console.log(hello)
+
+
diff --git a/_templates/generator/with-prompt/prompt.js b/_templates/generator/with-prompt/prompt.js
new file mode 100644
index 0000000..76ea532
--- /dev/null
+++ b/_templates/generator/with-prompt/prompt.js
@@ -0,0 +1,14 @@
+---
+to: _templates/<%= name %>/<%= action || 'new' %>/prompt.js
+---
+
+// see types of prompts:
+// https://github.com/enquirer/enquirer/tree/master/examples
+//
+module.exports = [
+ {
+ type: 'input',
+ name: 'message',
+ message: "What's your message?"
+ }
+]
diff --git a/_templates/package.json b/_templates/package.json
new file mode 100644
index 0000000..5bbefff
--- /dev/null
+++ b/_templates/package.json
@@ -0,0 +1,3 @@
+{
+ "type": "commonjs"
+}
diff --git a/_templates/story/new/index.js b/_templates/story/new/index.js
new file mode 100644
index 0000000..5a3f060
--- /dev/null
+++ b/_templates/story/new/index.js
@@ -0,0 +1,13 @@
+const path = require('path');
+
+module.exports = {
+ params: ({ args }) => {
+
+ const storypath = args.path.replace( '.svelte', '.stories.svelte' );
+
+ const component = path.basename(args.path.replace('/index.svelte','')).replace('.svelte','');
+
+ const to = path.join(path.dirname(args.path), component + '.stories.svelte' );
+ return { storypath, component, to}
+ }
+}
diff --git a/_templates/story/new/stories.svelte.temp b/_templates/story/new/stories.svelte.temp
new file mode 100644
index 0000000..25911ce
--- /dev/null
+++ b/_templates/story/new/stories.svelte.temp
@@ -0,0 +1,21 @@
+---
+to: <%= to %>
+---
+} argTypes={{}} />
+
+
+
+
+
+ <<%= component %> />
+
+
+
+
diff --git a/package.json b/package.json
index 7835ef8..bf57761 100644
--- a/package.json
+++ b/package.json
@@ -24,7 +24,7 @@
"eslint-plugin-svelte3": "^3.4.1",
"prettier": "~2.5.1",
"prettier-plugin-svelte": "^2.6.0",
- "storybook-builder-vite": "0.1.17",
+ "storybook-builder-vite": "0.1.21",
"svelte": "^3.46.4",
"vite": "^2.7.0"
},
diff --git a/src/lib/components/App.svelte b/src/lib/components/App.svelte
index d453b95..68ebcde 100644
--- a/src/lib/components/App.svelte
+++ b/src/lib/components/App.svelte
@@ -9,10 +9,14 @@
+
diff --git a/src/lib/components/Output/Print/Hull/index.svelte b/src/lib/components/Output/Print/Hull/index.svelte
index cffeaad..52b32c5 100644
--- a/src/lib/components/Output/Print/Hull/index.svelte
+++ b/src/lib/components/Output/Print/Hull/index.svelte
@@ -9,7 +9,7 @@
diff --git a/src/lib/components/Output/Print/Print.stories.svelte b/src/lib/components/Output/Print/Print.stories.svelte
new file mode 100644
index 0000000..af26b85
--- /dev/null
+++ b/src/lib/components/Output/Print/Print.stories.svelte
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/lib/components/Output/Print/Systems/Firecons/Firecons.stories.svelte b/src/lib/components/Output/Print/Systems/Firecons/Firecons.stories.svelte
new file mode 100644
index 0000000..83ad5f0
--- /dev/null
+++ b/src/lib/components/Output/Print/Systems/Firecons/Firecons.stories.svelte
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/lib/components/Output/Print/Systems/Firecons/index.svelte b/src/lib/components/Output/Print/Systems/Firecons/index.svelte
index 10ce7c2..673a3ce 100644
--- a/src/lib/components/Output/Print/Systems/Firecons/index.svelte
+++ b/src/lib/components/Output/Print/Systems/Firecons/index.svelte
@@ -1,11 +1,11 @@
- {#each _.range(firecons) as firecon}
+ {#each range(1,firecons) as firecon}
{/each}
diff --git a/src/lib/components/Output/Print/Systems/Screens/Screens.stories.svelte b/src/lib/components/Output/Print/Systems/Screens/Screens.stories.svelte
new file mode 100644
index 0000000..c4ffa23
--- /dev/null
+++ b/src/lib/components/Output/Print/Systems/Screens/Screens.stories.svelte
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/lib/components/Output/Print/Systems/Screens/index.svelte b/src/lib/components/Output/Print/Systems/Screens/index.svelte
index 5272361..400e569 100644
--- a/src/lib/components/Output/Print/Systems/Screens/index.svelte
+++ b/src/lib/components/Output/Print/Systems/Screens/index.svelte
@@ -1,14 +1,14 @@
- {#each _.range(standard) as i}
+ {#each range(1,standard) as i}
{/each}
- {#each _.range(advanced) as i}
+ {#each range(1,advanced) as i}
{/each}
diff --git a/src/lib/components/Output/Print/Weapons/index.svelte b/src/lib/components/Output/Print/Weapons/index.svelte
index edb7d6f..307318d 100644
--- a/src/lib/components/Output/Print/Weapons/index.svelte
+++ b/src/lib/components/Output/Print/Weapons/index.svelte
@@ -11,7 +11,7 @@
export let weapons = [];
let beams = [];
- $: beams = weapons.filter(({ weapon_type }) => weapon_type === "beam");
+ $: beams = weapons.filter(({ type }) => type === "beam");
diff --git a/src/lib/components/Output/Print/sample.js b/src/lib/components/Output/Print/sample.js
index 4c356b3..bd9352c 100644
--- a/src/lib/components/Output/Print/sample.js
+++ b/src/lib/components/Output/Print/sample.js
@@ -1,108 +1,105 @@
export default {
- ftl: {
- mass: 0,
- cost: 0,
- type: "standard",
+ "identification": {
+ "shipType": "Scout",
+ "shipClass": "Blah",
+ "isCarrier": false,
+ "mass": 10
},
- engine: {
- mass: 40,
- cost: 80,
- rating: 6,
- advanced: false,
- },
- general: {
- ship_class: "Deviant",
- name: "",
- ship_type: "Battleship",
- mass: 132,
- used_mass: 131,
- cost: 415,
- },
- weaponry: {
- firecons: {
- nbr: 5,
- mass: 5,
- cost: 20,
+ "propulsion": {
+ "drive": {
+ "reqs": {
+ "cost": 2,
+ "mass": 1
+ },
+ "rating": 3,
+ "advanced": true
},
- weapons: [
- {
- weapon_type: "submunition",
- arcs: ["F"],
- mass: 1,
- cost: 3,
- id: 1,
+ "ftl": {
+ "reqs": {
+ "cost": 0,
+ "mass": 0
},
- {
- weapon_type: "beam",
- weapon_class: "2",
- arcs: ["A", "AS", "FS"],
- mass: 2,
- cost: 6,
- id: 2,
+ "type": "none"
+ }
+ },
+ "structure": {
+ "hull": {
+ "reqs": {
+ "cost": 2,
+ "mass": 1
},
- {
- weapon_type: "pds",
- mass: 1,
- cost: 3,
- id: 3,
+ "rating": 10,
+ "min": 1,
+ "max": 10
+ },
+ "screens": {
+ "reqs": {
+ "cost": 0,
+ "mass": 0
},
+ "standard": 3,
+ "advanced": 2
+ },
+ "cargo": {
+ "reqs": {
+ "cost": 0,
+ "mass": 0
+ },
+ "space": 0
+ },
+ "streamlining": {
+ "reqs": {
+ "cost": 0,
+ "mass": 0
+ },
+ "type": "none"
+ },
+ "armor": {
+ "layers": [],
+ "reqs": {
+ "mass": 0,
+ "cost": 0
+ }
+ }
+ },
+ "carrier": {
+ "reqs": {
+ "cost": 0,
+ "mass": 0
+ },
+ "bays": 0,
+ "squadrons": []
+ },
+ "weaponry": {
+ "weapons": [
+ {
+ "id": 1,
+ "type": "beam",
+ "reqs": {
+ "mass": 1,
+ "cost": 3
+ },
+ "weaponClass": 1
+ }
],
- adfc: {
- rating: 0,
- cost: 0,
- mass: 0,
+ "firecons": {
+ "stations": 1,
+ "reqs": {
+ "cost": 4,
+ "mass": 1
+ }
},
+ "adfc": {
+ "rating": 1,
+ "reqs": {
+ "cost": 8,
+ "mass": 2
+ }
+ }
},
- structure: {
- mass: 0,
- cost: 0,
- hull: {
- rating: 22,
- advanced: false,
- cost: 44,
- mass: 22,
- },
- screens: {
- standard: 2,
- advanced: 1,
- cost: 105,
- mass: 35,
- },
- armour: [
- {
- layer: 1,
- rating: 7,
- cost: 14,
- mass: 14,
- },
- {
- layer: 2,
- rating: 2,
- cost: 8,
- mass: 4,
- },
- {
- layer: 3,
- rating: 0,
- cost: 0,
- mass: 0,
- },
- ],
- },
- cargo: {
- space: 7,
- cost: 0,
- mass: 7,
- },
- streamlining: {
- type: "none",
- cost: 0,
- mass: 0,
- },
- carrier: {
- bays: 0,
- cost: 0,
- mass: 0,
- squadrons: [],
- },
-};
+ "reqs": {
+ "cost": 19,
+ "mass": 10,
+ "usedMass": 6
+ }
+}
diff --git a/src/lib/components/Output/Print/stories.js b/src/lib/components/Output/Print/stories.js
deleted file mode 100644
index 858e5c1..0000000
--- a/src/lib/components/Output/Print/stories.js
+++ /dev/null
@@ -1,13 +0,0 @@
-import Print from "./index.svelte";
-import sample from "./sample";
-
-export default {
- title: "printouts",
-};
-
-export const basic = () => ({
- Component: Print,
- props: {
- ship: sample,
- },
-});
diff --git a/src/lib/shipDux/structure/armor.js b/src/lib/shipDux/structure/armor.js
index 9b43574..0724399 100644
--- a/src/lib/shipDux/structure/armor.js
+++ b/src/lib/shipDux/structure/armor.js
@@ -3,6 +3,20 @@ import u from "updeep";
import reqs from "../reqs.js";
+const schema = {
+ type: 'object',
+ properties: {
+ reqs: { type: 'object', properties: {
+ cost: { type: 'number' },
+ mass: { type: 'number' },
+ } },
+ layers: { type: 'array', items: 'number' }
+ },
+ examples: [
+ { reqs: { cost: 5, mass: 5 }, layers: [2,4 ] }
+ ]
+}
+
const dux = new Updux({
subduxes: {
reqs,
diff --git a/src/lib/utils.js b/src/lib/utils.js
new file mode 100644
index 0000000..79226cb
--- /dev/null
+++ b/src/lib/utils.js
@@ -0,0 +1,8 @@
+export function range(min, max) {
+ if(max === undefined) {
+ max = min;
+ min = 0;
+ }
+
+ return Array.from({length: 1+max - min}).map( (_d,i) => i+ min);
+}