vovk 0.2.3-beta.21 → 0.2.3-beta.23
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/cli/index.js +1 -6
- package/cli/postinstall.js +20 -0
- package/cli/server.js +1 -1
- package/package.json +2 -1
package/cli/index.js
CHANGED
|
@@ -106,12 +106,7 @@ if (argv._.includes('build')) {
|
|
|
106
106
|
options
|
|
107
107
|
);
|
|
108
108
|
|
|
109
|
-
void result
|
|
110
|
-
.catch((e) => console.error(e))
|
|
111
|
-
.then(async () => {
|
|
112
|
-
await generateClient(argv.rc, argv.output);
|
|
113
|
-
console.info(' 🐺 Both processes have completed and the client is generated.');
|
|
114
|
-
});
|
|
109
|
+
void result.catch((e) => console.error(e));
|
|
115
110
|
})
|
|
116
111
|
.catch(() => {
|
|
117
112
|
console.error(' 🐺 Failed to find available port.');
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const fs = require('fs/promises');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const fileExists = async (path) => !!(await fs.stat(path).catch(() => false));
|
|
5
|
+
|
|
6
|
+
async function postinstall() {
|
|
7
|
+
const vovk = path.join(__dirname, '../../.vovk');
|
|
8
|
+
const js = path.join(vovk, 'index.js');
|
|
9
|
+
const ts = path.join(vovk, 'index.ts');
|
|
10
|
+
|
|
11
|
+
if ((await fileExists(js)) || (await fileExists(ts))) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
await fs.mkdir(vovk, { recursive: true });
|
|
16
|
+
await fs.writeFile(js, '/* postinstall */');
|
|
17
|
+
await fs.writeFile(ts, '/* postinstall */');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
void postinstall();
|
package/cli/server.js
CHANGED
|
@@ -39,7 +39,6 @@ const writeMetadata = async (metadataPath, metadata) => {
|
|
|
39
39
|
const existingMetadata = await fs.readFile(metadataPath, 'utf-8').catch(() => '{}');
|
|
40
40
|
if (isEqual(JSON.parse(existingMetadata), metadata)) return;
|
|
41
41
|
await fs.writeFile(metadataPath, JSON.stringify(metadata, null, 2));
|
|
42
|
-
console.info(' 🐺 JSON data received and metadata file created');
|
|
43
42
|
};
|
|
44
43
|
|
|
45
44
|
const server = http.createServer((req, res) => {
|
|
@@ -59,6 +58,7 @@ const server = http.createServer((req, res) => {
|
|
|
59
58
|
await generateClient(argv.rc, argv.output);
|
|
60
59
|
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
61
60
|
res.end('JSON data received and file created');
|
|
61
|
+
console.info(' 🐺 JSON data received and the client is generated');
|
|
62
62
|
} catch (err) {
|
|
63
63
|
res.writeHead(400, { 'Content-Type': 'text/plain' });
|
|
64
64
|
res.end('Invalid JSON');
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vovk",
|
|
3
|
-
"version": "0.2.3-beta.
|
|
3
|
+
"version": "0.2.3-beta.23",
|
|
4
4
|
"description": "Structural add-on for Next.js",
|
|
5
5
|
"bin": "./cli/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
+
"postinstall": "node ./cli/postinstall.js",
|
|
7
8
|
"upgrade": "npx npm-check-updates -u && npm i",
|
|
8
9
|
"test": "npm run lint-nofix && tsc --noemit && npm run unit",
|
|
9
10
|
"unit": "PORT=3210 concurrently \"sleep 20 && npm run test:unit\" \"npm run serve:unit\" --kill-others --success first",
|