vovk 0.2.3-beta.112 → 0.2.3-beta.113

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 CHANGED
@@ -10,6 +10,7 @@ const parseCommandLineArgs = require('./lib/parseCommandLineArgs');
10
10
  const { command, flags, restArgs } = parseCommandLineArgs();
11
11
  const {
12
12
  config = path.join(process.cwd(), 'vovk.config.js'), // Path to vovk.config.js
13
+ // TODO not documented
13
14
  project = process.cwd(), // Path to Next.js project
14
15
  clientOut = path.join(process.cwd(), './node_modules/.vovk'), // Path to output directory
15
16
  } = flags;
@@ -42,26 +43,6 @@ if (command === 'dev') {
42
43
  ).catch((e) => console.error(e));
43
44
  console.info(' 🐺 All processes have ended');
44
45
  })();
45
- } else if (command === 'build') {
46
- void (async () => {
47
- const env = getVars(config, { VOVK_CLIENT_OUT: clientOut });
48
-
49
- let VOVK_PORT = parseInt(env.VOVK_PORT);
50
-
51
- env.VOVK_PORT = await getAvailablePort(VOVK_PORT, 30).catch(() => {
52
- throw new Error(' 🐺 Failed to find available port');
53
- });
54
- await parallel(
55
- [
56
- {
57
- command: `node ${__dirname}/server.js --once`,
58
- name: 'Vovk',
59
- },
60
- { command: `cd ${project} && npx next build ${restArgs}`, name: 'Next' },
61
- ],
62
- env
63
- ).catch((e) => console.error(e));
64
- })();
65
46
  } else if (command === 'generate') {
66
47
  const env = getVars(config, { VOVK_CLIENT_OUT: clientOut });
67
48
 
@@ -71,7 +52,6 @@ if (command === 'dev') {
71
52
  } else if (command === 'help') {
72
53
  console.info(` 🐺 Vovk CLI
73
54
  dev - Start development server
74
- build - Build Next.js project
75
55
  generate - Generate client
76
56
  help - Show this help message`);
77
57
  } else {
package/cli/server.js CHANGED
@@ -9,7 +9,7 @@ const isEqual = require('./lib/isEqual');
9
9
 
10
10
  const { flags } = parseCommandLineArgs();
11
11
 
12
- const { once, config } = /** @type {{ once?: boolean; config: string }} */ (flags);
12
+ const { config } = /** @type {{ config: string }} */ (flags);
13
13
 
14
14
  const metadataPath = path.join(__dirname, '../../../.vovk.json');
15
15
 
@@ -37,25 +37,31 @@ let pingInterval;
37
37
  let vars;
38
38
 
39
39
  /** @type {() => void} */
40
- const startPinging = () => {
41
- clearInterval(pingInterval);
42
- pingInterval = setInterval(() => {
43
- vars = vars ?? getVars(config);
44
- let prefix = vars.VOVK_PREFIX;
45
- prefix = prefix.startsWith('http://')
46
- ? prefix
47
- : `http://localhost:${process.env.PORT}/${prefix.startsWith('/') ? prefix.slice(1) : prefix}`;
48
- const endpoint = `${prefix.endsWith('/') ? prefix.slice(0, -1) : prefix}/__ping`;
49
- // Create the HTTP GET request
50
- const req = http.get(endpoint, () => {
51
- // noop
52
- });
40
+ const ping = () => {
41
+ vars = vars ?? getVars(config);
42
+ let prefix = vars.VOVK_PREFIX;
43
+ prefix = prefix.startsWith('http://')
44
+ ? prefix
45
+ : `http://localhost:${process.env.PORT}/${prefix.startsWith('/') ? prefix.slice(1) : prefix}`;
46
+ const endpoint = `${prefix.endsWith('/') ? prefix.slice(0, -1) : prefix}/__ping`;
47
+ // Create the HTTP GET request
48
+ const req = http.get(endpoint, () => {
49
+ // noop
50
+ });
51
+
52
+ // Error handling for the request
53
+ req.on('error', (err) => {
54
+ console.error(`🐺 ❌ Error during HTTP request made to ${endpoint}:`, err.message);
55
+ });
56
+ };
53
57
 
54
- // Error handling for the request
55
- req.on('error', (err) => {
56
- console.error(`🐺 ❌ Error during HTTP request made to ${endpoint}:`, err.message);
57
- });
58
- }, 1000 * 3);
58
+ // make initial ping
59
+ setTimeout(ping, 1000 * 3);
60
+
61
+ /** @type {() => void} */
62
+ const constantlyPing = () => {
63
+ clearInterval(pingInterval);
64
+ pingInterval = setInterval(ping, 1000 * 3);
59
65
  };
60
66
 
61
67
  const server = http.createServer((req, res) => {
@@ -84,18 +90,12 @@ const server = http.createServer((req, res) => {
84
90
  console.info(` 🐺 Client generated in ${codeWritten.path}`);
85
91
  }
86
92
 
87
- if (!once) {
88
- startPinging();
89
- }
90
-
91
- if (once && metadata) server.close();
93
+ constantlyPing();
92
94
  } catch (e) {
93
95
  const err = /** @type {Error} */ (e);
94
96
  res.writeHead(400, { 'Content-Type': 'text/plain' });
95
97
  res.end(err?.message ?? 'Error');
96
98
  console.error(' 🐺 ❌ ' + err?.message);
97
-
98
- if (once) server.close();
99
99
  }
100
100
  });
101
101
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vovk",
3
- "version": "0.2.3-beta.112",
3
+ "version": "0.2.3-beta.113",
4
4
  "description": "Structural add-on for Next.js",
5
5
  "bin": "./cli/index.js",
6
6
  "scripts": {
@@ -22,6 +22,7 @@
22
22
  "minor": "npm t && npm version minor && npm run build && npm publish ./dist && git push && git push --tags",
23
23
  "BREAKING-major": "npm t && npm version major && npm run build && npm publish ./dist && git push && git push --tags",
24
24
  "beta": "npm t && npm version prerelease --preid=beta && npm run build && npm publish ./dist --tag beta && git push && git push --tags",
25
+ "beta-notest": "npm version prerelease --preid=beta && npm run build && npm publish ./dist --tag beta && git push && git push --tags",
25
26
  "beta-patch": "npm t && npm version prepatch --preid=beta && npm run build && npm publish ./dist --tag beta && git push && git push --tags",
26
27
  "beta-minor": "npm t && npm version preminor --preid=beta && npm run build && npm publish ./dist --tag beta && git push && git push --tags",
27
28
  "BREAKING-beta-major": "npm t && npm version premajor --preid=beta && npm run build && npm publish ./dist --tag beta && git push && git push --tags"
@@ -51,16 +52,16 @@
51
52
  "@types/jest": "^29.5.12",
52
53
  "@types/lodash": "^4.14.202",
53
54
  "@types/supertest": "^6.0.2",
54
- "@typescript-eslint/eslint-plugin": "^6.20.0",
55
- "@typescript-eslint/parser": "^6.20.0",
55
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
56
+ "@typescript-eslint/parser": "^6.21.0",
56
57
  "eslint": "^8.56.0",
57
58
  "eslint-config-prettier": "^9.1.0",
58
59
  "eslint-plugin-prettier": "^5.1.3",
59
60
  "jest": "^29.7.0",
60
61
  "lodash": "^4.17.21",
61
62
  "next": "^14.1.0",
62
- "prettier": "^3.2.4",
63
- "puppeteer": "^21.10.0",
63
+ "prettier": "^3.2.5",
64
+ "puppeteer": "^22.0.0",
64
65
  "supertest": "^6.3.4",
65
66
  "ts-jest": "^29.1.2",
66
67
  "typescript": "^5.3.3",