manyfest 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,65 @@
1
+ # Use the codercom/code-server image
2
+ FROM codercom/code-server:latest
3
+ MAINTAINER steven velozo
4
+
5
+ VOLUME /home/coder/.config
6
+ VOLUME /home/coder/.vscode
7
+
8
+ RUN echo "...installing debian dependencies..."
9
+ RUN sudo apt update
10
+ RUN sudo apt install vim curl tmux -y
11
+ RUN sudo apt install default-mysql-server default-mysql-client -y
12
+ # RUN sudo apt install sysv-rc-conf -y
13
+
14
+ RUN echo "Building RETOLD development image..."
15
+
16
+ RUN echo "...configuring mariadb (mysql) server..."
17
+ RUN sudo sed -i "s|bind-address|#bind-address|g" /etc/mysql/mariadb.conf.d/50-server.cnf
18
+ ADD ./.config/luxury-extras/MySQL/MySQL-Security.sql /home/coder/MySQL-Configure-Security.sql
19
+ ADD ./.config/luxury-extras/MySQL/MySQL-Laden-Entry.sh /usr/bin/MySQL-Laden-Entry.sh
20
+ RUN sudo chmod +x /usr/bin/MySQL-Laden-Entry.sh
21
+ RUN ( sudo mysqld_safe --skip-grant-tables --skip-networking & ) && sleep 5 && mysql -u root < /home/coder/MySQL-Configure-Security.sql
22
+
23
+ # Enable MariaDB even without systemd
24
+ # RUN sudo sysv-rc-conf --level 0123456S mariadb on
25
+
26
+ # Import the initial database
27
+ RUN sudo service mariadb restart && sleep 5 && mysql -u root -p"123456789" -e "CREATE DATABASE YOURDATABASENAMEHERE;"
28
+
29
+ RUN echo "...installing vscode extensions..."
30
+ RUN code-server --install-extension ritwickdey.LiveServer \
31
+ code-server --install-extension hbenl.vscode-mocha-test-adapter \
32
+ code-server --install-extension hbenl.vscode-test-explorer \
33
+ code-server --install-extension hbenl.test-adapter-converter \
34
+ code-server --install-extension daylerees.rainglow \
35
+ code-server --install-extension oderwat.indent-rainbow \
36
+ code-server --install-extension evan-buss.font-switcher \
37
+ code-server --install-extension vscode-icons-team.vscode-icons \
38
+ code-server --install-extension bengreenier.vscode-node-readme \
39
+ code-server --install-extension bierner.color-info \
40
+ code-server --install-extension dbaeumer.vscode-eslint \
41
+ code-server --install-extension PKief.material-icon-theme
42
+
43
+ SHELL ["/bin/bash", "-c"]
44
+ USER coder
45
+
46
+ # Copy any default configs for the coding environment we want (e.g. dark theme)
47
+ # COPY ./.config/.default_home/ /home/coder/
48
+
49
+ RUN echo "...mapping library specific volumes..."
50
+ # Volume mappings for code
51
+ VOLUME /home/coder/YOURLIBRARYNAMEHERE
52
+ # VOLUME /home/coder/YOURLIBRARYNAMEHERE/node_modules
53
+
54
+ RUN echo "...installing node version manager..."
55
+ # Because there is a .bashrc chicken/egg problem, we will create one here to simulate logging in. This is not great.
56
+ RUN touch ~/.bashrc && chmod +x ~/.bashrc
57
+ RUN curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
58
+
59
+ RUN echo "...installing node version 14 as the default..."
60
+ RUN . ~/.nvm/nvm.sh && source ~/.bashrc && nvm install 14
61
+ RUN . ~/.nvm/nvm.sh && source ~/.bashrc && nvm alias default 14
62
+
63
+ WORKDIR /home/coder/YOURLIBRARYNAMEHERE
64
+
65
+ ENTRYPOINT ["/usr/bin/MySQL-Laden-Entry.sh"]
@@ -0,0 +1,17 @@
1
+ #!/bin/bash
2
+
3
+ trap 'kill -TERM $PID' TERM INT
4
+
5
+ /usr/bin/entrypoint.sh --bind-addr "0.0.0.0:8080" . &
6
+
7
+ PID=$!
8
+
9
+ sleep 2
10
+
11
+ sudo service mariadb restart
12
+
13
+ wait $PID
14
+ trap - TERM INT
15
+ wait $PID
16
+ EXIT_STATUS=$?
17
+ echo "Service exited with status ${EXIT_STATUS}"
@@ -0,0 +1,5 @@
1
+ FLUSH PRIVILEGES;
2
+
3
+ ALTER USER 'root'@'localhost' IDENTIFIED BY '123456789';
4
+
5
+ GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456789' WITH GRANT OPTION;
@@ -0,0 +1,46 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "name": "Launch Debug Harness",
9
+ "type": "pwa-node",
10
+ "request": "launch",
11
+ "outputCapture": "std",
12
+ "skipFiles": [
13
+ "<node_internals>/**"
14
+ ],
15
+ "program": "${workspaceFolder}/debug/Harness.js",
16
+ "presentation": {
17
+ "hidden": false,
18
+ "group": "",
19
+ "order": 1
20
+ }
21
+ },
22
+ {
23
+ "name": "Mocha Tests",
24
+ "args": [
25
+ "-u",
26
+ "tdd",
27
+ "--timeout",
28
+ "999999",
29
+ "--colors",
30
+ "${workspaceFolder}/test"
31
+ ],
32
+ "internalConsoleOptions": "openOnSessionStart",
33
+ "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
34
+ "request": "launch",
35
+ "skipFiles": [
36
+ "<node_internals>/**"
37
+ ],
38
+ "type": "pwa-node",
39
+ "presentation": {
40
+ "hidden": false,
41
+ "group": "",
42
+ "order": 2
43
+ }
44
+ }
45
+ ]
46
+ }
@@ -0,0 +1,39 @@
1
+ # Use the codercom/code-server image
2
+ FROM codercom/code-server:latest
3
+ MAINTAINER steven velozo
4
+
5
+ VOLUME /home/coder/.config
6
+ VOLUME /home/coder/.vscode
7
+
8
+ RUN echo "...installing debian dependencies..."
9
+ RUN sudo apt update
10
+ RUN sudo apt install vim curl tmux -y
11
+
12
+ RUN echo "Building development image..."
13
+
14
+ RUN echo "...installing vscode extensions..."
15
+ RUN code-server --install-extension ritwickdey.LiveServer \
16
+ code-server --install-extension hbenl.vscode-mocha-test-adapter \
17
+ code-server --install-extension hbenl.vscode-test-explorer \
18
+ code-server --install-extension hbenl.test-adapter-converter \
19
+ code-server --install-extension daylerees.rainglow \
20
+ code-server --install-extension oderwat.indent-rainbow
21
+
22
+ RUN echo "...mapping library specific volumes..."
23
+ # Volume mappings for code
24
+ VOLUME /home/coder/manyfest
25
+ # VOLUME /home/coder/manyfest/node_modules
26
+
27
+ SHELL ["/bin/bash", "-c"]
28
+ USER coder
29
+
30
+ RUN echo "...installing node version manager..."
31
+ # Because there is a .bashrc chicken/egg problem, we will create one here to simulate logging in. This is not great.
32
+ RUN touch ~/.bashrc && chmod +x ~/.bashrc
33
+ RUN curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
34
+
35
+ RUN echo "...installing node version 14 as the default..."
36
+ RUN . ~/.nvm/nvm.sh && source ~/.bashrc && nvm install 14
37
+ RUN . ~/.nvm/nvm.sh && source ~/.bashrc && nvm alias default 14
38
+
39
+ WORKDIR /home/coder/manyfest
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Steven Velozo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,234 @@
1
+ # Manyfest
2
+
3
+ ## JSON Object Manifest for Data Description and Parsing
4
+
5
+ We focus so much on documentation and description for the mechanics of data at rest, in software development. Schema for databases. Well-named variables in code, with comments. Expressive languages for writing software or querying graphs of information.
6
+
7
+ As data crosses these boundaries, though, context is lost. We reinvent the wheel at each layer! The front-end code has its own mechanism for putting a label before a value to the user. It is rare that there are less than three representations of an important piece of data across:
8
+
9
+ * The Data Persistence Engine _(e.g. a SQL server table, or schemaless storage)_
10
+ * Middle Tier Source Code _(e.g. an API service)_
11
+ * Front End Source Code _(e.g. the code behind for a single page app)_
12
+ * The User Interface _(e.g. a label on a web form)_
13
+
14
+ Manyfest's purpose is to solve this problem by creating a simple pattern to describe, validate, manipulate and interpret data.
15
+
16
+ ![Official Mascot](https://github.com/stevenvelozo/manyfest/raw/main/diagrams/Mascot.jpg)
17
+
18
+ _Man-E-Faces approves of Manyfest!_
19
+
20
+ ## Where Does this Run
21
+
22
+ Either of a stand-alone library in node.js software, or, a dependency-free browser library.
23
+
24
+ ### Compatiblity
25
+
26
+ This library is tested for node.js versions 8 through 16, and will likely work in future versions. It is implemented as a simple set of es6 classes.
27
+
28
+ The browser version has been packaged into a minified as well as an expanded debuggable library. Sourcemaps are included.
29
+
30
+ ## Installation
31
+
32
+ For use within node.js, run the following in the folder with your `package.json` file:
33
+
34
+ ```
35
+ npm install --save Manyfest
36
+ ```
37
+
38
+ Then, you can include it in your source code as follows:
39
+
40
+ ```
41
+ const libManyfest = require('Manyfest');
42
+
43
+ // Construct a Manyfest with a few defined columns
44
+ let animalManyfest = new libManyfest(
45
+ {
46
+ "Scope": "Animal",
47
+ "Descriptors":
48
+ {
49
+ "IDAnimal": { "Name":"Database ID", "Description":"The unique integer-based database identifier for an Animal record.", "DataType":"Integer" },
50
+ "Name": { "Description":"The animal's colloquial species name (e.g. Rabbit, Dog, Bear, Mongoose)." },
51
+ "Type": { "Description":"Whether or not the animal is wild, domesticated, agricultural, in a research lab or a part of a zoo.." }
52
+ }
53
+ });
54
+
55
+ // Make up a cute and furry test creature
56
+ let testAnimal = {IDAnimal:8675309, Name:'BatBrains', Type:'Lab', Color:'Brown'};
57
+
58
+ // Validate an Object Against the Manyfest
59
+ let validateResults = animalManyfest.validate(testAnimal);
60
+
61
+ console.log(JSON.stringify(validateResults,null,4));
62
+ ```
63
+
64
+ The code above sets up a Manyfest, and runs a validation on the testAnimal. The validation will come back all good telling us which properties aren't in the object but are described. If the `strict` option has been set, missing described elements of an object without data are treated as errors. If there are any `Required` columns, they are always errors if they are missing.
65
+
66
+ Error does not mean the software throws an exception. It comes back as well-formed JSON.
67
+
68
+ ## Lexicon
69
+
70
+ Below is a lexicon of terms used throughout this documentation. If you see anything missing, want more elaboration or just dislike a particular term, please file an issue in github!
71
+
72
+ | Term | Description |
73
+ | Scope | The scope of this representation; generally the clustered or parent record name (e.g. Animal, User, Transaction, etc.) -- does not have functional purpose; only for information and logging. |
74
+ | Schema | The stateful representation of an object's structural definition. |
75
+ | Element | A defined element of data in an object. |
76
+ | Address | The address where that data lies in the object. |
77
+ | Descriptor | A description of an element including data such as Name, NameShort, Hash, Description, and other important properties. |
78
+ | Name | The name of the element. Meant to be the most succinct human readable name possible. |
79
+ | NameShort | A shorter name for the element. Meant to be useful enough to identify the property in log lines, tabular views, graphs and anywhere where we don't always want to see the full name. |
80
+ | Description | A description for the element. Very useful when consuming other APIs with their own terse naming standards (or no naming standards)! |
81
+ | Hash | A unique within this scope string-based key for this element. Used for easy access of data. |
82
+ | Constraint | A validation constraint for an element such as MaxLength, MinLength, Required, Default and such. |
83
+
84
+ ## A More Advanced Schema Example
85
+
86
+ Addresses are meant to be kinda magic. They describe locations in nested JSON just as well as simple objects. Further, they can allow us to manipulate and read JSON values at specific addresses.
87
+
88
+
89
+ Let's use our Animal schema and extend it a little bit. In this case, a new JSON sub object needs to be included carrying important medical information about this animal.
90
+
91
+ ```
92
+ let animalManyfest = new libManyfest(
93
+ {
94
+ "Scope": "Animal",
95
+ "Descriptors":
96
+ {
97
+ "IDAnimal": { "Name":"Database ID", "Description":"The unique integer-based database identifier for an Animal record.", "DataType":"Integer" },
98
+ "Name": { "Description":"The animal's colloquial species name (e.g. Rabbit, Dog, Bear, Mongoose)." },
99
+ "Type": { "Description":"Whether or not the animal is wild, domesticated, agricultural, in a research lab or a part of a zoo.." },
100
+ "MedicalStats":
101
+ {
102
+ "Name":"Medical Statistics", "Description":"Basic medical statistics for this animal"
103
+ },
104
+ "MedicalStats.Temps.MinET": { "Name":"Minimum Environmental Temperature", "NameShort":"MinET", "Description":"Safest minimum temperature for this animal to survive in."},
105
+ "MedicalStats.Temps.MaxET": { "Name":"Maximum Environmental Temperature", "NameShort":"MaxET", "Description":"Safest maximum temperature for this animal to survive in."},
106
+ "MedicalStats.Temps.CET":
107
+ {
108
+ "Name":"Comfortable Environmental Temperature",
109
+ "NameShort":"Comf Env Temp",
110
+ "Hash":"ComfET",
111
+ "Description":"The most comfortable temperature for this animal to survive in."}
112
+ }
113
+ });
114
+ ```
115
+
116
+ Notice in this example, the addresses are more complex. They have a dot syntax. This notifies Manyfest that they are nested values. Further, there is both a Name and a NameShort descriptor setup. This gives us a framework for consistently referring to the data element both internally and to the user. It is no longer a mystery what someAnimal.MedicalStats.Temps.CET means. Developers, user interface designers, database engineers, product managers and other folks who work on the software side don't have to maintain a third body of documentation about what the data means.
117
+
118
+ To aid in this discovery, reference and such, we've given it a NameShort (for use in things like tabular views and graphs/charts), a longer Name and a Hash (to enable easy reading and writing using the object element read/write functions described later in this documentation).
119
+
120
+ ## Reading and Writing Element Properties
121
+
122
+ Lastly, when working with objects, Manyfest provides a set of functions to read and write from/to these element addresses. This can be useful for consistently accessing objects across boundaries as well as filling out element defaults without requiring a crazy amount of boilerplate code.
123
+
124
+ ### An Example and the Why of Reading and Writing Element Properties
125
+
126
+ For instance, if you have an element with the address of "MedicalStats.HeartRate.RestingHeartRate.OverallAverage" (which is very verbose; most JSON object structures are not so descriptive) it would take a significant amount of code to write that to an empty object.
127
+
128
+ #### The Typical Javascript Way of Reading
129
+
130
+ In the example below, the read and write code throws an error. You could work around it with:
131
+
132
+ * a bunch of sequential guards
133
+ * use fancy new es6 syntax with the `someObject.?SomeContainer.?OtherContainer.Property` _(although that isn't compatible with older services and browsers that run older versions of javascript)_
134
+ * write some kind of complex handler for it
135
+ * something else clever?
136
+
137
+ ```
138
+ // Write Code
139
+ let newAnimal = {};
140
+
141
+ // This is going to make a terrible error happen
142
+ newAnimal.MedicalStats.HeartReat.RestingHeartRate.OverallAverage = 61;
143
+ ```
144
+
145
+ ```
146
+ // Read Code
147
+ let newAnimal = {};
148
+
149
+ // This is going to make a terrible error happen
150
+ console.log(newAnimal.MedicalStats.HeartReat.RestingHeartRate.OverallAverage);
151
+
152
+ // My javascript interpreter said this when I tried this code:
153
+ // > Uncaught TypeError: Cannot read properties of undefined (reading 'HeartReat')
154
+ ```
155
+
156
+ #### The Manyfest Way
157
+
158
+ However with the Manyfest reading and writing methods you can do this (all in one example since it doesn't blow up):
159
+
160
+ ```
161
+ let newAnimal = {};
162
+
163
+ // You can now try to access the value on a "clean" object...
164
+ console.log(animalManyfest.getValueAtAddress(newAnimal, "MedicalStats.HeartRate.RestingHeartRate.OverallAverage"));
165
+
166
+ // The output prints out "undefined" ... because it is!
167
+
168
+ // This will be helpful and create the necessary structure inbetween
169
+ animalManyfest.setValueAtAddress(newAnimal, "MedicalStats.HeartRate.RestingHeartRate.OverallAverage", 61);
170
+
171
+ // You can now access the value as well...
172
+ console.log(animalManyfest.getValueAtAddress(newAnimal, "MedicalStats.HeartRate.RestingHeartRate.OverallAverage"));
173
+
174
+ // The output prints out "61"
175
+ ```
176
+
177
+ #### That's Not All!
178
+
179
+ Because we have mappings to and from more human readable names to the addresses, we can happily use either the Name or Hash for these lookups. For instance, from the example above, if we have our Comfortable Environmental Temperature for an animal which was in the address `someAnimal.MedicalStats.Temps.CET` and had a hash of `ComfET`, a developer could easily access it by hash (assuming the `favoriteAnimalAPI` function returns a JSON representation of my favorite animal):
180
+
181
+ ```
182
+ let favAnimal = favoriteAnimalAPI();
183
+
184
+ console.log(animalManyfest.getValueByHash(favAnimal,'ComfET'));
185
+ ```
186
+
187
+ For any elements that haven't defined a Hash, the Address is used. This allows code to gracefully fall back.
188
+
189
+ ## Programmatically Defining a Schema
190
+
191
+ Sometimes we don't have schemas, and want to define object element structure on the fly. This can be done programmatically. As a refresher, here is how we loaded our simplest schema manifest above:
192
+
193
+ ```
194
+ const libManyfest = require('Manyfest');
195
+
196
+ // Construct a Manyfest with a few defined columns
197
+ let animalManyfest = new libManyfest(
198
+ {
199
+ "Scope": "Animal",
200
+ "Descriptors":
201
+ {
202
+ "IDAnimal": { "Name":"Database ID", "Description":"The unique integer-based database identifier for an Animal record.", "DataType":"Integer" },
203
+ "Name": { "Description":"The animal's colloquial species name (e.g. Rabbit, Dog, Bear, Mongoose)." },
204
+ "Type": { "Description":"Whether or not the animal is wild, domesticated, agricultural, in a research lab or a part of a zoo.." }
205
+ }
206
+ });
207
+ ```
208
+
209
+ The programmatic equivalent is the following code:
210
+
211
+ ```
212
+ const libManyfest = require('Manyfest');
213
+
214
+ // Construct a Manyfest with a few defined columns
215
+ let animalManyfest = new libManyfest();
216
+
217
+ // Set the Scope
218
+ animalManyfest.Scope = "Animal";
219
+
220
+ // Add descriptors
221
+ animalManyfest.addDescriptor("IDAnimal", { "Name":"Database ID", "Description":"The unique integer-based database identifier for an Animal record.", "DataType":"Integer" });
222
+ animalManyfest.addDescriptor("Name", { "Description":"The animal's colloquial species name (e.g. Rabbit, Dog, Bear, Mongoose)." });
223
+ animalManyfest.addDescriptor("Type", { "Description":"Whether or not the animal is wild, domesticated, agricultural, in a research lab or a part of a zoo.." });
224
+
225
+ // Now you can work with the animalManyfest just as we did in the other method.
226
+ ```
227
+
228
+ Programmatic definition is interesting because you can start with a pre-defined manifest and add on elements later if you like. This can be useful if you, say, have an endpoint which generally returns a record, but, sometimes decorates it with connected records for developer convenience.
229
+
230
+ ## Other Uses
231
+
232
+ Have you ever tried to code against a weather API? They use *so many* different structures of data. And once you've used their structure, you are kindof stuck with it.
233
+
234
+ With manyfest, you can easily create a description for each API and code against getting values by hash. This abstracts the complexity of multiple API services without requiring you to marshal it into your own persistence format.
@@ -0,0 +1,20 @@
1
+ let libManyfest = require(`../source/Manyfest.js`);
2
+
3
+ let animalManyfest = new libManyfest(
4
+ {
5
+ "Scope": "Animal",
6
+ "Descriptors":
7
+ {
8
+ "IDAnimal": { "Name":"Database ID", "Description":"The unique integer-based database identifier for an Animal record.", "DataType":"Integer" },
9
+ "Name": { "Description":"The animal's colloquial species name (e.g. Rabbit, Dog, Bear, Mongoose)." },
10
+ "Type": { "Description":"Whether or not the animal is wild, domesticated, agricultural, in a research lab or a part of a zoo.." }
11
+ }
12
+ });
13
+
14
+ // Make up a cute and furry test creature
15
+ let testAnimal = {IDAnimal:8675309, Name:'BatBrains', Type:'Lab', Color:'Brown'};
16
+
17
+ // Check the Manyfest
18
+ let checkResults = animalManyfest.validate(testAnimal);
19
+
20
+ console.log(JSON.stringify(checkResults,null,4));
Binary file
package/gulpfile.js ADDED
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ const libBrowserify = require('browserify');
4
+ const libGulp = require('gulp');
5
+
6
+ const libVinylSourceStream = require('vinyl-source-stream');
7
+ const libVinylBuffer = require('vinyl-buffer');
8
+
9
+ const libTerser = require('gulp-terser');
10
+ const libBuble = require('gulp-buble');
11
+ const libSourcemaps = require('gulp-sourcemaps');
12
+ const libGulpUtil = require('gulp-util');
13
+
14
+ // Build the module for the browser
15
+ // This gulp task is taken from the gulp recipe repository:
16
+ // https://github.com/gulpjs/gulp/blob/master/docs/recipes/browserify-uglify-sourcemap.md
17
+ libGulp.task('minified',
18
+ () => {
19
+ // set up the custom browserify instance for this task
20
+ var tmpBrowserify = libBrowserify(
21
+ {
22
+ entries: './source/Manyfest-Browser-Shim.js',
23
+ standalone: 'Fable',
24
+ debug: true
25
+ });
26
+
27
+ return tmpBrowserify.bundle()
28
+ .pipe(libVinylSourceStream('manyfest.min.js'))
29
+ .pipe(libVinylBuffer())
30
+ .pipe(libSourcemaps.init({loadMaps: true}))
31
+ // Add transformation tasks to the pipeline here.
32
+ .pipe(libTerser())
33
+ .on('error', libGulpUtil.log)
34
+ .pipe(libSourcemaps.write('./'))
35
+ .pipe(libGulp.dest('./dist/'));
36
+ });
37
+
38
+ // Build the module for the browser
39
+ // This gulp task is taken from the gulp recipe repository:
40
+ // https://github.com/gulpjs/gulp/blob/master/docs/recipes/browserify-uglify-sourcemap.md
41
+ libGulp.task('debug',
42
+ () => {
43
+ // set up the custom browserify instance for this task
44
+ var tmpBrowserify = libBrowserify(
45
+ {
46
+ entries: './source/Manyfest-Browser-Shim.js',
47
+ standalone: 'Manyfest',
48
+ debug: true
49
+ });
50
+
51
+ return tmpBrowserify.bundle()
52
+ .pipe(libVinylSourceStream('manyfest.js'))
53
+ .pipe(libVinylBuffer())
54
+ .on('error', libGulpUtil.log)
55
+ .pipe(libGulp.dest('./dist/'));
56
+ });
57
+
58
+ libGulp.task
59
+ (
60
+ 'build',
61
+ libGulp.series('debug', 'minified')
62
+ );
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "manyfest",
3
+ "version": "1.0.0",
4
+ "description": "JSON Object Manifest for Data Description and Parsing",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "docker-dev-build-image": "docker build ./ -f Dockerfile_LUXURYCode -t retold/manyfest:local",
8
+ "docker-dev-run": "docker run -it -d --name manyfest -p 12340:8080 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/manyfest\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" retold/manyfest:local",
9
+ "test": "./node_modules/mocha/bin/_mocha -u tdd -R spec",
10
+ "tests": "./node_modules/mocha/bin/_mocha -u tdd -R spec --grep"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/stevenvelozo/manyfest.git"
15
+ },
16
+ "keywords": [
17
+ "manifest",
18
+ "data",
19
+ "description",
20
+ "json"
21
+ ],
22
+ "mocha": {
23
+ "diff": true,
24
+ "extension": [
25
+ "js"
26
+ ],
27
+ "package": "./package.json",
28
+ "reporter": "spec",
29
+ "slow": "75",
30
+ "timeout": "5000",
31
+ "ui": "tdd",
32
+ "watch-files": [
33
+ "source/**/*.js",
34
+ "test/**/*.js"
35
+ ],
36
+ "watch-ignore": [
37
+ "lib/vendor"
38
+ ]
39
+ },
40
+ "devDependencies": {
41
+ "@babel/core": "^7.17.9",
42
+ "@babel/preset-env": "^7.16.11",
43
+ "@testing-library/dom": "^8.13.0",
44
+ "async": "^3.2.3",
45
+ "browserify": "^17.0.0",
46
+ "chai": "4.3.6",
47
+ "gulp": "^4.0.2",
48
+ "gulp-babel": "^8.0.0",
49
+ "gulp-buble": "^0.9.0",
50
+ "gulp-sourcemaps": "^3.0.0",
51
+ "gulp-terser": "^2.1.0",
52
+ "gulp-util": "^3.0.8",
53
+ "jsdom": "^19.0.0",
54
+ "mocha": "9.2.2",
55
+ "npm-check-updates": "^12.5.9",
56
+ "nyc": "^15.1.0",
57
+ "vinyl-buffer": "^1.0.1",
58
+ "vinyl-source-stream": "^2.0.0"
59
+ },
60
+ "dependencies": {},
61
+ "author": "steven velozo <steven@velozo.com>",
62
+ "license": "MIT",
63
+ "bugs": {
64
+ "url": "https://github.com/stevenvelozo/manyfest/issues"
65
+ },
66
+ "homepage": "https://github.com/stevenvelozo/manyfest#readme"
67
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @license MIT
3
+ * @author <steven@velozo.com>
4
+ */
5
+
6
+ /**
7
+ * Manyfest browser shim loader
8
+ */
9
+
10
+ // Load the manyfest module into the browser global automatically.
11
+ var libManyfest = require('./Manyfest.js');
12
+
13
+ if (typeof(window) === 'object') window.Manyfest = libManyfest;
14
+
15
+ module.exports = libManyfest;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license MIT
3
+ * @author <steven@velozo.com>
4
+ */
5
+
6
+ /**
7
+ * Manyfest simple logging shim (for browser and dependency-free running)
8
+ */
9
+
10
+ const logToConsole = (pLogLine, pLogObject) =>
11
+ {
12
+ let tmpLogLine = (typeof(pLogLine) === 'string') ? pLogLine : '';
13
+
14
+ console.log(`[Manyfest] ${tmpLogLine}`);
15
+
16
+ if (pLogObject) console.log(JSON.stringify(tmpLogObject,null,4)+"\n");
17
+ };
18
+
19
+ module.exports = logToConsole;