dsst
v1.1.3
Published
Divine Star Script Tool
Downloads
5
Maintainers
Readme
Dependencies
What It Does
This is a tool to create different versions of scripts. Simply it lets you define different code sections with a unqiue comment and either include or remove those code sections to create different versions. You define where you want the tool to pull scripts from and where you want the scripts to be put.
Uses
- Create different versions of the same program for different environments.
- Create auto backups of scripts.
- Create development and testing versions.
- Use the same code base for multiple projects and have them auto sync.
- Detect file changes and auto copy changed files to a different location.
How does it work?
For instance if we have this simple script:
//@ds-test-start
tester.runTest();
//@ds-test-end
//@ds-perf-start
tester.runPerfTest();
//@ds-perf-end
If you run the tool it will prune out the code sections and make different versions for each defined output.
So, if you wanted a build with just performance testing code you could use this tool to do that.
Or if you were developing code that has some minor changes for either different backends or platforms you could use to have the same codebase for both versions and auto sync the code to the different environments.
How To Use
This is a command line tool. To install this you must have node and npm installed. First you must install it globally on your system.
npm install -g dsst
After that it pretty simple to use. Here are the commands:
Commands
| Command | Description |
| --------------- | --------------- |
| dsst --cc | Generate a default config file |
| dsst --c | Override the default config file name. The defautl is .dsconfig
|
| dsst -p | Parse and deploy scripts. |
| dsst -a | Watch for changes and auto parse and deploy scripts. |
| dsst -i | Get info about the program. |
| dsst --help | In case you need more info. |
Before you can use the tool you need to set up a config file.
Use the command "dsst --cc" to make a default one in the directory you are currently in.
It should then generate the following file.
{
"sources": [
{
"dir": "/",
"fileExtensions": [
"js"
],
"id": "main"
}
],
"outputs": [
{
"dir": "/test/",
"sourceID": "main",
"codeSection": [
"test",
"log"
],
"keepComments": false
},
{
"dir": "/perf/",
"sourceID": "main",
"codeSection": [
"perf"
],
"keepComments": false
},
{
"dir": "/dev/",
"sourceID": "main",
"codeSection": [
"dev"
],
"keepComments": false
},
{
"dir": "/backup/",
"sourceID": "main",
"codeSection": "All",
"keepComments": false
}
],
"codeSections": {
"test": {
"start": "@ds-test-start",
"end": "@ds-test-end"
},
"log": {
"start": "@ds-test-log",
"end": "@ds-test-log"
},
"perf": {
"start": "@ds-test-perf",
"end": "@ds-test-perf"
},
"dev": {
"start": "@ds-test-dev",
"end": "@ds-test-dev"
}
}
}
From here you can set up the config however you like.
The next section goes over each part of the config file.
The Config File
The tool requires a config file to run.
Sources
"sources": [
{
"dir": "/",
"fileExtensions": [
"js"
],
"id": "main"
}
]
The sources param defines all the locations in which the tool will pull scripts from.
It is an array that takes objects with 3 properities.
Source Properties
| Property | Description | | --------------- | --------------- | | dir | The directory to pull scripts from. | | fileExtensions | The file extensions to include. | | id | An idea to identify the source. Must be unique. |
Outputs
"outputs": [
{
"dir": "/test/",
"sourceID": "main",
"codeSection": [
"test",
"log"
],
"keepComments": false
},
]
The outputs param defines all the locations in which the tool will put scripts and what to do with them.
It is an array that takes objects with 4 properities.
Outputs Properties
| Property | Description | | --------------- | --------------- | | dir | The directory to put scripts. | | sourceID | The id for the source to pull scripts from. | | codeSection* | An array of strings of code sections to include. | | | keepComments | A boolean if set to false it will remove comments from the exported scripts. |
*Can also be string value of "all" to include all sections or "none" to remove all code sections.
Sources
"codeSections": {
"test": {
"start": "@ds-test-start",
"end": "@ds-test-end"
}
}
The codeSections param defines all the code sections and their delimiters.
It is an object that has a map of the code sections.
You define a code section by adding a new entry to the object with the following properties:
Code Section Properties
| Property | Description | | --------------- | --------------- | | start | The unique starting string for a code section. | | end | The unique ending string for a code section. |
NOTE: The script will be looking for the start or end string with "//" appened to the front. Since these tags are meant to be used in commments like this:
//CODE_SECTION_TAG
Later there will be more options for different languages that do not suppourt comments with forward slashes. If you have any request pleasse make an issue.
Command Output
Config Validation
If you run either the parse or auto command you will see this sequence:
.
,X,
,XOX,
'xooooOOOOOoooox'
`XOOOOOOOOOX`
`XOOOOOX`
XOOX'XOOX
XOX' 'XOX
X' 'X
[ Divine Star Script Tool ]
Searching for config data...
Found config data.
Validating config data.
==============================
Validating sources...
Sources are good.
Validating outputs...
Outputs are good.
Validating code sections...
Code sections are good.
Data is good.
This is an example of a config file that passed all the test.
The script does some type checking and makes sure things are linked together correctly between the outputs and sources.
This is to ensure no errors occur when running the program and to prevent potential unwanted effects.
Script Parse
If you run the script parse command and or the auto command you will see this sequence if everything went correctly.
{-----------------------------}
[ Divine Star Script Tool ]
Running Script Parse
{-----------------------------}
==============================
Searching for script source.
D:/Divine Star Games/GAMES/IRRCODERAW/js
Found folder
Starting script mapping.
==============================
Finished Script Map
Starting script pruning.
==============================
Scripts were pruned.
Starting deploying..
==============================
Scripts succesfully deployed
Auto
If you run the auto command you will first see the parse screen and then this screen.
{-----------------------------}
[ Divine Star Script Tool ]
Running Auto Mode
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
{-----------------------------}
DIRECTORY_TO_WATCH
Once you make an update in the directory a message will appear showing that it got the update and that it parsed and deployed the file.
It should look something like this:
{-----------------------------}
[ Divine Star Script Tool ]
Running Auto Mode
|0|0|0|0|0|0XXXXXXXXXXXXXXXXXXX}
{-----------------------------}
{----==== UP TO DATE ====----}
{-----------------------------}
TIME STAMP: 10:9:1 9/10/2021
[ UPDATE ]
FILE CHANGED
---
/index.js
{-----------------------------}