@datapos/datapos-development 0.3.18 → 0.3.21
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/.vscode/settings.json +7 -0
- package/LICENSES.json +1 -1
- package/README.md +46 -48
- package/index.js +12 -12
- package/package.json +9 -6
- /package/{LICENSE.md → LICENSE} +0 -0
package/LICENSES.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
[]
|
package/README.md
CHANGED
|
@@ -1,66 +1,64 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Data Positioning Development Library
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@datapos/datapos-development)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](#)
|
|
6
|
+
|
|
7
|
+
A library of JavaScript operations for managing the Data Positioning repositories.
|
|
4
8
|
|
|
5
9
|
## Requirements
|
|
6
10
|
|
|
7
11
|
Ensure your environment meets the following prerequisites before using this library:
|
|
8
12
|
|
|
9
|
-
- **Node.js** version `>=18.0.0
|
|
10
|
-
- **npm** version `>=9.0.0
|
|
11
|
-
- A Unix-like shell (for command shortcuts, e.g., `bash`, `zsh`, or Git Bash on Windows)
|
|
12
|
-
- Access to the [npm registry](https://www.npmjs.com/) and [GitHub](https://github.com/) for publishing and syncing
|
|
13
|
+
- **Node.js** version `>=18.0.0`,
|
|
14
|
+
- **npm** version `>=9.0.0`,
|
|
15
|
+
- A Unix-like shell (for command shortcuts, e.g., `bash`, `zsh`, or Git Bash on Windows),
|
|
16
|
+
- Access to the [npm registry](https://www.npmjs.com/) and [GitHub](https://github.com/) for publishing and syncing.
|
|
13
17
|
|
|
14
18
|
## Installation
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
npm install -D @datapos/datapos-development
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Dependencies
|
|
21
|
-
|
|
22
|
-
| Name | Use | References |
|
|
23
|
-
| -------- | --- | ------------------ |
|
|
24
|
-
| eslint | dev | [GitHub]() [NPM]() |
|
|
25
|
-
| nanoid | dev | [GitHub]() [NPM]() |
|
|
26
|
-
| prettier | dev | [GitHub]() [NPM]() |
|
|
27
|
-
| run | dev | [GitHub]() [NPM]() |
|
|
20
|
+
Install as a development (dev) dependency:
|
|
28
21
|
|
|
29
|
-
|
|
22
|
+
```bash
|
|
23
|
+
npm install --save-dev @datapos/datapos-development
|
|
24
|
+
```
|
|
30
25
|
|
|
31
26
|
## Operations
|
|
32
27
|
|
|
33
28
|
The 'index.js' file exposes the following operations:
|
|
34
29
|
|
|
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
|
|
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.
|
|
30
|
+
| Name | Notes |
|
|
31
|
+
| ------------------------- | ------------------------------------------------------------------------ |
|
|
32
|
+
| buildConfig | Build the config.json file for the repository. |
|
|
33
|
+
| buildPublicDirectoryIndex | Build an index for the repositories public directory. |
|
|
34
|
+
| bumpVersion | Bump the repositories version number. |
|
|
35
|
+
| clearDirectory | Clear the specified directory. |
|
|
36
|
+
| sendDeploymentNotice | Send a deployment notice for the repository. |
|
|
37
|
+
| syncWithGitHub | Synchronise the local repository with the main GitHub repository. |
|
|
38
|
+
| uploadDirectoryToR2 | Upload a directory to Cloudflare R2 storage. |
|
|
39
|
+
| uploadModuleConfig | Upload a modules configuration to the Cloudflare `state` durable object. |
|
|
40
|
+
| uploadModuleToR2 | Upload a module to Cloudflare R2 storage. |
|
|
46
41
|
|
|
47
42
|
## Repository Management Commands
|
|
48
43
|
|
|
49
|
-
The
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
| check | alt+ctrl+shift+c |
|
|
57
|
-
| document | alt+ctrl+shift+d |
|
|
58
|
-
| format | alt+ctrl+shift+f |
|
|
59
|
-
| lint | alt+ctrl+shift+l |
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
44
|
+
The table below lists the repository management commands available in this project.
|
|
45
|
+
For detailed implementation, see the `scripts` section in `package.json`.
|
|
46
|
+
|
|
47
|
+
| Name | Key Code | Notes |
|
|
48
|
+
| ------------------ | ---------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
49
|
+
| audit | alt+ctrl+shift+a | Audit the project's dependencies for known security vulnerabilities. |
|
|
50
|
+
| build | alt+ctrl+shift+b | NOT implemented. |
|
|
51
|
+
| check | alt+ctrl+shift+c | List outdated dependencies. |
|
|
52
|
+
| document | alt+ctrl+shift+d | Identify licenses of the project's production and peer dependencies. See [LICENSES.json](./LICENSES.json). |
|
|
53
|
+
| format | alt+ctrl+shift+f | Enforce formatting style rules. |
|
|
54
|
+
| lint | alt+ctrl+shift+l | Check the code for errors and enforce coding style rules. |
|
|
55
|
+
| release | alt+ctrl+shift+r | Bump version, synchronise local repository with the main GitHub repository and publish to npm. |
|
|
56
|
+
| syncWithGitHub | alt+ctrl+shift+s | Bump version and synchronise local repository with the main GitHub repository. |
|
|
57
|
+
| test | alt+ctrl+shift+t | NOT implemented. |
|
|
58
|
+
| updateDependencies | alt+ctrl+shift+u | NOT implemented. |
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
[MIT](./LICENSE) © 2026 Data Positioning Pty Ltd
|
|
63
|
+
|
|
64
|
+
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fdata-positioning%2Fdatapos-development?ref=badge_large&issueType=license)
|
package/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
// Dependencies
|
|
1
|
+
// Dependencies
|
|
2
2
|
const fs = require('fs').promises;
|
|
3
3
|
const { nanoid } = require('nanoid');
|
|
4
4
|
|
|
5
|
-
// Dependencies -
|
|
5
|
+
// Dependencies - Promisify exec.
|
|
6
6
|
const util = require('util');
|
|
7
7
|
const exec = util.promisify(require('child_process').exec);
|
|
8
8
|
|
|
9
|
-
// Operations - Build
|
|
9
|
+
// Operations - Build configuration.
|
|
10
10
|
async function buildConfig(directoryPath) {
|
|
11
11
|
const configJSON = await readJSONFile(`${directoryPath || ''}config.json`);
|
|
12
12
|
const packageJSON = await readJSONFile('package.json');
|
|
13
13
|
await fs.writeFile(`${directoryPath || ''}config.json`, JSON.stringify({ ...configJSON, id: packageJSON.name, version: packageJSON.version }, undefined, 4));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
// Operations - Build
|
|
16
|
+
// Operations - Build public directory index.
|
|
17
17
|
async function buildPublicDirectoryIndex(id) {
|
|
18
18
|
const index = {};
|
|
19
19
|
|
|
@@ -50,7 +50,7 @@ async function buildPublicDirectoryIndex(id) {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
// Operations - Bump
|
|
53
|
+
// Operations - Bump version.
|
|
54
54
|
async function bumpVersion() {
|
|
55
55
|
const packageJSON = await readJSONFile('package.json');
|
|
56
56
|
const versionSegments = packageJSON.version.split('.');
|
|
@@ -59,7 +59,7 @@ async function bumpVersion() {
|
|
|
59
59
|
console.log(`Bumped to version ${packageJSON.version}.`);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
// Operations - Clear
|
|
62
|
+
// Operations - Clear directory.
|
|
63
63
|
async function clearDirectory(directoryPath) {
|
|
64
64
|
for (const itemName of await fs.readdir(directoryPath)) {
|
|
65
65
|
const itemPath = `${directoryPath}/${itemName}`;
|
|
@@ -76,7 +76,7 @@ async function clearDirectory(directoryPath) {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
// Operations - Send
|
|
79
|
+
// Operations - Send deployment notice.
|
|
80
80
|
async function sendDeploymentNotice() {
|
|
81
81
|
const configJSON = await readJSONFile('config.json');
|
|
82
82
|
const options = {
|
|
@@ -88,7 +88,7 @@ async function sendDeploymentNotice() {
|
|
|
88
88
|
if (!response.ok) console.log(await response.text());
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
// UtilitiesOperations - Sync with
|
|
91
|
+
// UtilitiesOperations - Sync with GitHub.
|
|
92
92
|
async function syncWithGitHub() {
|
|
93
93
|
const packageJSON = await readJSONFile('package.json');
|
|
94
94
|
await exec('git add .');
|
|
@@ -96,7 +96,7 @@ async function syncWithGitHub() {
|
|
|
96
96
|
await exec('git push origin main:main');
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
// Operations - Upload
|
|
99
|
+
// Operations - Upload directory to Cloudflare R2.
|
|
100
100
|
async function uploadDirectoryToR2(sourceDirectory, uploadDirectory) {
|
|
101
101
|
async function listDirectoryEntriesRecursively(currentSourceDirectory, currentDestinationDirectory, names) {
|
|
102
102
|
for (const name of names) {
|
|
@@ -125,7 +125,7 @@ async function uploadDirectoryToR2(sourceDirectory, uploadDirectory) {
|
|
|
125
125
|
await listDirectoryEntriesRecursively(`${sourceDirectory}/${uploadDirectory}`, uploadDirectory, toplevelNames);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
// Operations - Upload
|
|
128
|
+
// Operations - Upload module configuration.
|
|
129
129
|
async function uploadModuleConfig() {
|
|
130
130
|
const configJSON = await readJSONFile('config.json');
|
|
131
131
|
const stateId = configJSON.id;
|
|
@@ -138,14 +138,14 @@ async function uploadModuleConfig() {
|
|
|
138
138
|
if (!response.ok) console.log(await response.text());
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
// Operations - Upload
|
|
141
|
+
// Operations - Upload module to Cloudflare R2.
|
|
142
142
|
async function uploadModuleToR2(fromPath, toPath) {
|
|
143
143
|
const packageJSON = await readJSONFile('package.json');
|
|
144
144
|
const toPathWithVersion = toPath.replace(/^(.*?\.)/, `$1v${packageJSON.version}.`);
|
|
145
145
|
await exec(`wrangler r2 object put ${toPathWithVersion} --file=dist/${fromPath} --content-type application/javascript --jurisdiction=eu --remote`, { stdio: 'inherit' });
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
// Utilities - Read JSON
|
|
148
|
+
// Utilities - Read JSON file.
|
|
149
149
|
async function readJSONFile(path) {
|
|
150
150
|
try {
|
|
151
151
|
return JSON.parse(await fs.readFile(path, 'utf8'));
|
package/package.json
CHANGED
|
@@ -4,21 +4,24 @@
|
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
|
-
"version": "0.3.
|
|
7
|
+
"version": "0.3.21",
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"eslint": "^9.
|
|
9
|
+
"eslint": "^9.36.0",
|
|
10
|
+
"license-report": "^6.8.0",
|
|
11
|
+
"license-report-check": "^0.1.2",
|
|
10
12
|
"nanoid": "^5.1.5",
|
|
11
|
-
"
|
|
13
|
+
"npm-check-updates": "^18.3.0",
|
|
14
|
+
"prettier": "^3.6.2",
|
|
12
15
|
"run": "^1.5.0"
|
|
13
16
|
},
|
|
14
17
|
"scripts": {
|
|
15
18
|
"audit": "npm audit",
|
|
16
19
|
"build": "echo \"***** BUILD SCRIPT NOT IMPLEMENTED. *****\"",
|
|
17
20
|
"bumpVersion": "node -e \"import('./index.js').then(m => m.bumpVersion())\"",
|
|
18
|
-
"check": "
|
|
19
|
-
"document": "
|
|
21
|
+
"check": "npm outdated; npm-check-updates -i",
|
|
22
|
+
"document": "license-report --only=prod,peer > LICENSES.json && license-report-check --source ./LICENSES.json --allowed 'MIT' --allowed 'n/a' --allowed 'Apache-2.0' --output=table",
|
|
20
23
|
"format": "prettier --write *.js",
|
|
21
|
-
"lint": "
|
|
24
|
+
"lint": "eslint *.js",
|
|
22
25
|
"publishToNPM": "npm publish --access public",
|
|
23
26
|
"release": "npm run syncWithGitHub && npm run publishToNPM",
|
|
24
27
|
"syncWithGitHub": "npm run bumpVersion && node -e \"import('./index.js').then(m => m.syncWithGitHub())\"",
|
/package/{LICENSE.md → LICENSE}
RENAMED
|
File without changes
|