base-volta-off-of-nwjs 0.0.1
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/.editorconfig +17 -0
- package/CODE_OF_CONDUCT.md +55 -0
- package/LICENSE +21 -0
- package/README.md +16 -0
- package/index.js +199 -0
- package/package.json +31 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# EditorConfig is awesome: http://EditorConfig.org
|
|
2
|
+
|
|
3
|
+
# Top-most EditorConfig file
|
|
4
|
+
root = true
|
|
5
|
+
|
|
6
|
+
# defaults for all files
|
|
7
|
+
[*]
|
|
8
|
+
charset = utf-8
|
|
9
|
+
end_of_line = lf
|
|
10
|
+
indent_size = 2
|
|
11
|
+
indent_style = space
|
|
12
|
+
insert_final_newline = true
|
|
13
|
+
trim_trailing_whitespace = true
|
|
14
|
+
|
|
15
|
+
# Markdown files uses two trailing spaces to indicate a <br>
|
|
16
|
+
[*.{md,snap}]
|
|
17
|
+
trim_trailing_whitespace = false
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# "No Ideologies" Code of Conduct
|
|
2
|
+
|
|
3
|
+
The following are the guidelines we expect our community members and maintainers to follow.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Terminology and Scope
|
|
8
|
+
|
|
9
|
+
**What defines a "maintainer"?**
|
|
10
|
+
|
|
11
|
+
- A maintainer is anyone that interacts with the community on behalf of this project. Amount of code written is not a qualifier. A maintainer may include those who solely help in support roles such as in resolving issues, improving documentation, administrating or moderating forums/chatrooms, or any other non-coding specific roles. Maintainers also include those that are responsible for the building and upkeep of the project.
|
|
12
|
+
|
|
13
|
+
**What defines a "community member"?**
|
|
14
|
+
|
|
15
|
+
- Anyone interacting with this project directly, including maintainers.
|
|
16
|
+
|
|
17
|
+
**What is the scope of these guidelines?**
|
|
18
|
+
|
|
19
|
+
- These guidelines apply only to this project and forms of communication directly related to it, such as issue trackers, forums, chatrooms, and in person events specific to this project. If a member is violating these guidelines outside of this project or on other platforms, that is beyond our scope and any grievances should be handled on those platforms.
|
|
20
|
+
|
|
21
|
+
**Discussing the guidelines:**
|
|
22
|
+
|
|
23
|
+
- Discussions around these guidelines, improving, updating, or altering them, is permitted so long as the discussions do not violate any existing guidelines.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Guidelines
|
|
28
|
+
|
|
29
|
+
### Guidelines for community members
|
|
30
|
+
|
|
31
|
+
This project is technical in nature and not based around any particular non-technical ideology. As such, communication that is based primarily around ideologies unrelated to the technologies used by this repository are not permitted.
|
|
32
|
+
|
|
33
|
+
Any discussion or communication that is primarily focused around an ideology, be it about race, gender, politics, religion, or anything else non-technical, is not allowed. Everyone has their own ideological preferences, beliefs, and opinions. We do not seek to marginalize, exclude, or judge anyone for their ideologies. To prevent conflict between those with differing or opposing ideologies, all communication on these subjects are prohibited. Some discussions around these topics may be important, however this project is not the proper channel for these discussions.
|
|
34
|
+
|
|
35
|
+
### Guidelines for maintainers
|
|
36
|
+
|
|
37
|
+
- Maintainers must abide by the same rules as all other community members mentioned above. However, in addition, maintainers are held to a higher standard, explained below.
|
|
38
|
+
- Maintainers should answer all questions politely.
|
|
39
|
+
- If someone is upset or angry about something, it's probably because it's difficult to use, so thank them for bringing it to your attention and address ways to solve the problem. Maintainers should focus on the content of the message, and not on how it was delivered.
|
|
40
|
+
- A maintainer should seek to update members when an issue they brought up is resolved.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Appropriate response to violations
|
|
45
|
+
|
|
46
|
+
How to respond to a community member or maintainer violating a guideline.
|
|
47
|
+
|
|
48
|
+
1. If an issue is created that violates a guideline a maintainer should close and lock the issue, explaining "This issue is in violation of our code of conduct. Please review it before posting again." with a link to this document.
|
|
49
|
+
1. If a member repeatedly violates the guidelines established in this document, they should be politely warned that continuing to violate the rules may result in being banned from the community. This means revoking access and support to interactions relating directly to the project (issue trackers, chatrooms, forums, in person events, etc.). However, they may continue to use the technology in accordance with its license.
|
|
50
|
+
1. If a maintainer is in violation of a guideline, they should be informed of such with a link to this document. If additional actions are required of the maintainer but not taken, then other maintainers should be informed of these inactions.
|
|
51
|
+
1. If a maintainer repeatedly violates the guidelines established in this document, they should be politely warned that continuing to violate the rules may result in being banned from the community. This means revoking access and support to interactions relating directly to the project (issue trackers, chatrooms, forums, in person events, etc.). However, they may continue to use the technology in accordance with its license. In addition, future contributions to this project may be ignored as well.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
Based on version 1.0.3 from https://github.com/CodifiedConduct/coc-no-ideologies
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 NW.js Utilities
|
|
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,16 @@
|
|
|
1
|
+
# base-volta-off-of-nwjs
|
|
2
|
+
|
|
3
|
+
Updates the Volta config in your `package.json` so your Node.js version will match the version of Node.js built in to NW.js.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
1. `npm pkg set scripts.postinstall="npx base-volta-off-of-nwjs"`
|
|
9
|
+
|
|
10
|
+
This will add a command to your npm scripts that will automatically run after every time you do an `npm install`. It will update the Volta object in your `package.json` so the `node` value will match
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
1. You must have `nw` listed in `dependencies` or `devDependencies`
|
|
16
|
+
1. `nw` must be installed in the `node_modules` folder
|
package/index.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { promises as fs } from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import * as url from 'node:url';
|
|
6
|
+
|
|
7
|
+
let https;
|
|
8
|
+
try {
|
|
9
|
+
https = await import('node:https');
|
|
10
|
+
} catch (error) {
|
|
11
|
+
console.error('https support is disabled!');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
15
|
+
|
|
16
|
+
let originalManifestIndentation = 2;
|
|
17
|
+
let originalManifestEOL = '\n';
|
|
18
|
+
|
|
19
|
+
function fileExists (file) {
|
|
20
|
+
return fs.access(file, fs.constants.F_OK)
|
|
21
|
+
.then(() => {
|
|
22
|
+
return true;
|
|
23
|
+
})
|
|
24
|
+
.catch(() => {
|
|
25
|
+
return false;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getVersions () {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
const request = https.get('https://nwjs.io/versions.json', (response) => {
|
|
32
|
+
response.setEncoding('utf8');
|
|
33
|
+
let responseBody = '';
|
|
34
|
+
|
|
35
|
+
response.on('data', (chunk) => {
|
|
36
|
+
responseBody += chunk;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
response.on('end', () => {
|
|
40
|
+
try {
|
|
41
|
+
responseBody = JSON.parse(responseBody);
|
|
42
|
+
resolve(responseBody);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
reject(error);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
request.on('error', (error) => {
|
|
50
|
+
reject(error);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getLocalNwManifestPath () {
|
|
56
|
+
return new Promise(async (resolve, reject) => {
|
|
57
|
+
const nwManifestRelativeToHere = path.resolve(__dirname, '..', 'nw', 'package.json');
|
|
58
|
+
const nwManifestRelativeToCwd = path.resolve(process.cwd(), 'node_modules', 'nw', 'package.json');
|
|
59
|
+
const hereExists = await fileExists(nwManifestRelativeToHere);
|
|
60
|
+
const cwdExists = await fileExists(nwManifestRelativeToCwd);
|
|
61
|
+
if (hereExists) {
|
|
62
|
+
resolve(nwManifestRelativeToHere);
|
|
63
|
+
} else if (cwdExists) {
|
|
64
|
+
resolve(nwManifestRelativeToCwd);
|
|
65
|
+
} else {
|
|
66
|
+
reject(new Error('Could not locate nw node module manifest.'));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function getLocalNwManifest () {
|
|
72
|
+
return new Promise(async (resolve, reject) => {
|
|
73
|
+
try {
|
|
74
|
+
const nwManifest = await getLocalNwManifestPath();
|
|
75
|
+
let data = await fs.readFile(nwManifest, 'binary');
|
|
76
|
+
data = JSON.parse(data);
|
|
77
|
+
resolve(data);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
reject(error);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function getCorrectNodeVersion () {
|
|
85
|
+
return new Promise(async (resolve, reject) => {
|
|
86
|
+
try {
|
|
87
|
+
const nwManifest = await getLocalNwManifest();
|
|
88
|
+
const allNwVersions = await getVersions();
|
|
89
|
+
|
|
90
|
+
const localNwVersion = nwManifest?.version;
|
|
91
|
+
const match = allNwVersions.versions.find(function (version) {
|
|
92
|
+
return version.version === 'v' + localNwVersion;
|
|
93
|
+
});
|
|
94
|
+
if (!match) {
|
|
95
|
+
throw 'No matching NW.js version found';
|
|
96
|
+
}
|
|
97
|
+
const nodeVersion = match?.components?.node;
|
|
98
|
+
if (nodeVersion) {
|
|
99
|
+
resolve(nodeVersion);
|
|
100
|
+
} else {
|
|
101
|
+
throw 'No Node version found';
|
|
102
|
+
}
|
|
103
|
+
} catch (error) {
|
|
104
|
+
reject(error);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function determineOriginalManifestIndentation (data) {
|
|
110
|
+
data = data.trim();
|
|
111
|
+
data = data.replaceAll('\r\n', '\n');
|
|
112
|
+
|
|
113
|
+
if (data[0] !== '{' || data[1] !== '\n') {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
let first = data[2];
|
|
118
|
+
let second = data[3];
|
|
119
|
+
let third = data[4];
|
|
120
|
+
let fourth = data[5];
|
|
121
|
+
|
|
122
|
+
if (first === '\t') {
|
|
123
|
+
originalManifestIndentation = '\t';
|
|
124
|
+
} else if (first + second + third + fourth === ' ') {
|
|
125
|
+
originalManifestIndentation = 4;
|
|
126
|
+
} else {
|
|
127
|
+
originalManifestIndentation = 2;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function determinOriginalEOL (data) {
|
|
132
|
+
if (data.includes('\r\n')) {
|
|
133
|
+
originalManifestEOL = '\r\n';
|
|
134
|
+
} else {
|
|
135
|
+
originalManifestEOL = '\n';
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function getManifestPath () {
|
|
140
|
+
return new Promise(async (resolve, reject) => {
|
|
141
|
+
const manifestRelativeToHere = path.resolve(__dirname, '..', '..', 'package.json');
|
|
142
|
+
const manifestRelativeToCwd = path.resolve(process.cwd(), 'package.json');
|
|
143
|
+
const hereExists = await fileExists(manifestRelativeToHere);
|
|
144
|
+
const cwdExists = await fileExists(manifestRelativeToCwd);
|
|
145
|
+
if (hereExists) {
|
|
146
|
+
resolve(manifestRelativeToHere);
|
|
147
|
+
} else if (cwdExists) {
|
|
148
|
+
resolve(manifestRelativeToCwd);
|
|
149
|
+
} else {
|
|
150
|
+
reject(new Error('Could not locate your manifest.'));
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function getManifest () {
|
|
156
|
+
return new Promise(async (resolve, reject) => {
|
|
157
|
+
try {
|
|
158
|
+
const manifest = await getManifestPath();
|
|
159
|
+
let data = await fs.readFile(manifest, 'binary');
|
|
160
|
+
determineOriginalManifestIndentation(String(data));
|
|
161
|
+
determinOriginalEOL(String(data));
|
|
162
|
+
data = JSON.parse(data);
|
|
163
|
+
resolve(data);
|
|
164
|
+
} catch (error) {
|
|
165
|
+
reject(error);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function getManifestWithUpdatedVoltaObject () {
|
|
171
|
+
return new Promise(async (resolve, reject) => {
|
|
172
|
+
try {
|
|
173
|
+
const manifest = await getManifest();
|
|
174
|
+
const nodeVersion = await getCorrectNodeVersion();
|
|
175
|
+
manifest.volta = manifest.volta || {};
|
|
176
|
+
manifest.volta.node = nodeVersion;
|
|
177
|
+
resolve(manifest);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
reject(error);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async function run () {
|
|
185
|
+
try {
|
|
186
|
+
const manifestPath = await getManifestPath();
|
|
187
|
+
|
|
188
|
+
let mutatedManifest = await getManifestWithUpdatedVoltaObject();
|
|
189
|
+
mutatedManifest = JSON.stringify(mutatedManifest, null, originalManifestIndentation);
|
|
190
|
+
mutatedManifest = mutatedManifest.replaceAll('\r\n', '\n').replaceAll('\n', originalManifestEOL);
|
|
191
|
+
mutatedManifest = mutatedManifest + originalManifestEOL;
|
|
192
|
+
|
|
193
|
+
await fs.writeFile(manifestPath, mutatedManifest);
|
|
194
|
+
} catch (error) {
|
|
195
|
+
console.error(error);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
run();
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "base-volta-off-of-nwjs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"bin": "./index.js",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"description": "Updates Volta config in package.json so Node match's what your NW.js version uses",
|
|
8
|
+
"scripts": {
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/nwutils/base-volta-off-of-nwjs.git"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"nw.js",
|
|
16
|
+
"volta",
|
|
17
|
+
"node.js",
|
|
18
|
+
"version",
|
|
19
|
+
"management",
|
|
20
|
+
"automated"
|
|
21
|
+
],
|
|
22
|
+
"author": "TheJaredWilcurt",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/nwutils/base-volta-off-of-nwjs/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/nwutils/base-volta-off-of-nwjs#readme",
|
|
27
|
+
"volta": {
|
|
28
|
+
"node": "21.4.0",
|
|
29
|
+
"npm": "10.2.4"
|
|
30
|
+
}
|
|
31
|
+
}
|