@datapos/datapos-development 0.2.29 → 0.3.10
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.
- package/LICENSE.md +18 -4
- package/README.md +28 -28
- package/index.js +11 -6
- package/package.json +3 -2
package/LICENSE.md
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright
|
|
3
|
+
Copyright (c) 2015 DataPos Pty Ltd
|
|
4
4
|
|
|
5
|
-
Permission
|
|
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:
|
|
6
11
|
|
|
7
|
-
|
|
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# DataPos Development Library
|
|
2
2
|
|
|
3
|
-
A library of JavaScript
|
|
3
|
+
A library of JavaScript operations for managing the DataPos repositories.
|
|
4
4
|
|
|
5
5
|
## Requirements
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ Ensure your environment meets the following prerequisites before using this libr
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
16
|
```
|
|
17
|
-
npm install -D @datapos-development
|
|
17
|
+
npm install -D @datapos/datapos-development
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## Dependencies
|
|
@@ -28,39 +28,39 @@ npm install -D @datapos-development
|
|
|
28
28
|
|
|
29
29
|
Refer to package.json and LICENSES.json for detailed versions and licenses.
|
|
30
30
|
|
|
31
|
-
##
|
|
31
|
+
## Operations
|
|
32
32
|
|
|
33
33
|
The 'index.js' file exposes the following operations:
|
|
34
34
|
|
|
35
|
-
| Name | Notes
|
|
36
|
-
| ------------------------- |
|
|
37
|
-
| buildConfig |
|
|
38
|
-
| buildPublicDirectoryIndex |
|
|
39
|
-
| bumpVersion |
|
|
40
|
-
| clearDirectory |
|
|
41
|
-
| sendDeploymentNotice |
|
|
42
|
-
| syncWithGitHub |
|
|
43
|
-
| uploadDirectoryToR2 |
|
|
44
|
-
| uploadModuleConfig |
|
|
45
|
-
| uploadModuleToR2 |
|
|
35
|
+
| Name | Notes |
|
|
36
|
+
| ------------------------- | ----------------------------------------------------------------- |
|
|
37
|
+
| buildConfig | Build the config.json file for the repository. |
|
|
38
|
+
| buildPublicDirectoryIndex | Build an index for the repositories public directory. |
|
|
39
|
+
| bumpVersion | Bump the repositories version number. |
|
|
40
|
+
| clearDirectory | Clear the specified directory. |
|
|
41
|
+
| sendDeploymentNotice | Send a deployment notice fro the repository. |
|
|
42
|
+
| syncWithGitHub | Synchronise the local repository with the main GitHub repository. |
|
|
43
|
+
| uploadDirectoryToR2 | Upload a directory to Cloudflare R2 storage. |
|
|
44
|
+
| uploadModuleConfig | |
|
|
45
|
+
| uploadModuleToR2 | Upload a module to Cloudflare R2 storage. |
|
|
46
46
|
|
|
47
47
|
## Repository Management Commands
|
|
48
48
|
|
|
49
49
|
The following list details the repository management commands implemented by this project:
|
|
50
50
|
|
|
51
|
-
| Name | Key Code | Notes
|
|
52
|
-
| ------------------ | ---------------- |
|
|
53
|
-
| audit | alt+ctrl+shift+a | Use [npm audit](https://docs.npmjs.com/cli/v8/commands/npm-audit) to audit the project's dependencies for known security vulnerabilities.
|
|
54
|
-
| build | alt+ctrl+shift+b | NOT
|
|
55
|
-
| bumpVersion | |
|
|
56
|
-
| check | alt+ctrl+shift+c | Use [npx npm-check-updates](https://github.com/raineorshine/npm-check-updates) and [npm outdated](https://docs.npmjs.com/cli/v8/commands/npm-audit) to list the dependencies in the project that are outdated.
|
|
57
|
-
| document | alt+ctrl+shift+d | Use [npm-license-crawler](https://www.npmjs.com/package/npm-license-crawler) to identify the licenses of the project's direct production dependencies.
|
|
58
|
-
| format | alt+ctrl+shift+f | Use [prettier](https://prettier.io/) to format the code.
|
|
59
|
-
| lint | alt+ctrl+shift+l | Use [eslint](https://eslint.org/) to check the code for potential errors and
|
|
60
|
-
| publishToNPM | alt+ctrl+shift+n | Use [npm publish](https://docs.npmjs.com/cli/v8/commands/npm-publish) to publish the package to the [npm](https://www.npmjs.com/) registry. This action will publish the last synchronised version.
|
|
61
|
-
| release | alt+ctrl+shift+r | Synchronise the local repository with the main GitHub repository and publish the package to the [npm](https://www.npmjs.com/) registry.
|
|
62
|
-
| syncWithGitHub | alt+ctrl+shift+s | Synchronise the local repository with the main GitHub repository.
|
|
63
|
-
| test | alt+ctrl+shift+t | NOT
|
|
64
|
-
| updateDependencies | alt+ctrl+shift+u | NOT
|
|
51
|
+
| Name | Key Code | Notes |
|
|
52
|
+
| ------------------ | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
53
|
+
| audit | alt+ctrl+shift+a | Use [npm audit](https://docs.npmjs.com/cli/v8/commands/npm-audit) to audit the project's dependencies for known security vulnerabilities. |
|
|
54
|
+
| build | alt+ctrl+shift+b | \*** NOT IMPLEMENTED \*** |
|
|
55
|
+
| bumpVersion | | |
|
|
56
|
+
| check | alt+ctrl+shift+c | Use [npx npm-check-updates](https://github.com/raineorshine/npm-check-updates) and [npm outdated](https://docs.npmjs.com/cli/v8/commands/npm-audit) to list the dependencies in the project that are outdated. |
|
|
57
|
+
| document | alt+ctrl+shift+d | Use [npm-license-crawler](https://www.npmjs.com/package/npm-license-crawler) to identify the licenses of the project's direct production dependencies. |
|
|
58
|
+
| format | alt+ctrl+shift+f | Use [prettier](https://prettier.io/) to format the code. |
|
|
59
|
+
| lint | alt+ctrl+shift+l | Use [eslint](https://eslint.org/) to check the code for potential errors and enforce coding styles. |
|
|
60
|
+
| publishToNPM | alt+ctrl+shift+n | Use [npm publish](https://docs.npmjs.com/cli/v8/commands/npm-publish) to publish the package to the [npm](https://www.npmjs.com/) registry. This action will publish the last synchronised version. |
|
|
61
|
+
| release | alt+ctrl+shift+r | Synchronise the local repository with the main GitHub repository and publish the package to the [npm](https://www.npmjs.com/) registry. |
|
|
62
|
+
| syncWithGitHub | alt+ctrl+shift+s | Synchronise the local repository with the main GitHub repository. |
|
|
63
|
+
| test | alt+ctrl+shift+t | \*** NOT IMPLEMENTED \*** |
|
|
64
|
+
| updateDependencies | alt+ctrl+shift+u | \*** NOT IMPLEMENTED \*** |
|
|
65
65
|
|
|
66
66
|
For more details, please refer to the scripts section of the 'package.json' file in this project.
|
package/index.js
CHANGED
|
@@ -10,11 +10,13 @@ const exec = util.promisify(require('child_process').exec);
|
|
|
10
10
|
async function buildConfig() {
|
|
11
11
|
const configJSON = await readJSONFile('src/config.json');
|
|
12
12
|
const packageJSON = await readJSONFile('package.json');
|
|
13
|
-
fs.writeFile('src/config.json', JSON.stringify({ ...configJSON, id: packageJSON.name, version: packageJSON.version }, undefined, 4));
|
|
13
|
+
await fs.writeFile('src/config.json', JSON.stringify({ ...configJSON, id: packageJSON.name, version: packageJSON.version }, undefined, 4));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// Operations - Build Public Directory Index
|
|
17
17
|
async function buildPublicDirectoryIndex(id) {
|
|
18
|
+
const index = {};
|
|
19
|
+
|
|
18
20
|
async function listDirectoryEntriesRecursively(directoryPath, names) {
|
|
19
21
|
const entries = [];
|
|
20
22
|
const localDirectoryPath = directoryPath.substring(`public/${id}`.length);
|
|
@@ -34,13 +36,16 @@ async function buildPublicDirectoryIndex(id) {
|
|
|
34
36
|
console.error(`Unable to get information for '${name}' in 'buildPublicDirectoryIndex'.`, error);
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
|
-
entries.sort((left, right) => right.typeId.localeCompare(left.typeId) || left.name.localeCompare(right.name));
|
|
39
|
+
// TODO: Prior version: entries.sort((left, right) => right.typeId.localeCompare(left.typeId) || left.name.localeCompare(right.name));
|
|
40
|
+
entries.sort((left, right) => {
|
|
41
|
+
const typeComparison = left.typeId.localeCompare(right.typeId);
|
|
42
|
+
return typeComparison !== 0 ? typeComparison : left.name.localeCompare(right.name);
|
|
43
|
+
});
|
|
38
44
|
}
|
|
39
45
|
|
|
40
|
-
const index = {};
|
|
41
46
|
const toplevelNames = await fs.readdir(`public/${id}`);
|
|
42
47
|
await listDirectoryEntriesRecursively(`public/${id}`, toplevelNames);
|
|
43
|
-
fs.writeFile(`./public/${id}Index.json`, JSON.stringify(index), (error) => {
|
|
48
|
+
await fs.writeFile(`./public/${id}Index.json`, JSON.stringify(index), (error) => {
|
|
44
49
|
if (error) return console.error(error);
|
|
45
50
|
});
|
|
46
51
|
}
|
|
@@ -50,7 +55,7 @@ async function bumpVersion() {
|
|
|
50
55
|
const packageJSON = await readJSONFile('package.json');
|
|
51
56
|
const versionSegments = packageJSON.version.split('.');
|
|
52
57
|
packageJSON.version = `${versionSegments[0]}.${versionSegments[1]}.${Number(versionSegments[2]) + 1}`;
|
|
53
|
-
fs.writeFile('package.json', JSON.stringify(packageJSON, undefined, 4));
|
|
58
|
+
await fs.writeFile('package.json', JSON.stringify(packageJSON, undefined, 4));
|
|
54
59
|
console.log(`Bumped to version ${packageJSON.version}.`);
|
|
55
60
|
}
|
|
56
61
|
|
|
@@ -137,7 +142,7 @@ async function uploadModuleConfig() {
|
|
|
137
142
|
async function uploadModuleToR2(fromPath, toPath) {
|
|
138
143
|
const packageJSON = await readJSONFile('package.json');
|
|
139
144
|
const toPathWithVersion = toPath.replace(/^(.*?\.)/, `$1v${packageJSON.version}.`);
|
|
140
|
-
exec(`wrangler r2 object put ${toPathWithVersion} --file=dist/${fromPath} --content-type application/javascript --jurisdiction=eu --remote`, { stdio: 'inherit' });
|
|
145
|
+
await exec(`wrangler r2 object put ${toPathWithVersion} --file=dist/${fromPath} --content-type application/javascript --jurisdiction=eu --remote`, { stdio: 'inherit' });
|
|
141
146
|
}
|
|
142
147
|
|
|
143
148
|
// Utilities - Read JSON File
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datapos/datapos-development",
|
|
3
|
-
"license": "
|
|
3
|
+
"license": "MIT",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"version": "0.3.10",
|
|
7
8
|
"devDependencies": {
|
|
8
9
|
"eslint": "^9.28.0",
|
|
9
10
|
"nanoid": "^5.1.5",
|