quapp 1.0.2 → 1.0.4
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/build.js +89 -21
- package/package.json +16 -5
- package/server.js +4 -1
package/build.js
CHANGED
|
@@ -2,6 +2,7 @@ import { execSync } from "child_process";
|
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import { rm } from "fs/promises";
|
|
4
4
|
import path from "path";
|
|
5
|
+
import prompts from "prompts";
|
|
5
6
|
import archiver from "archiver";
|
|
6
7
|
import { fileURLToPath } from "url";
|
|
7
8
|
|
|
@@ -23,15 +24,78 @@ const __dirname = path.dirname(__filename);
|
|
|
23
24
|
const projectRoot = process.cwd();
|
|
24
25
|
const distFolder = path.join(projectRoot, "dist");
|
|
25
26
|
const outputQpp = path.join(projectRoot, "dist.qpp");
|
|
27
|
+
const packageJsonPath = path.join(projectRoot, "package.json");
|
|
28
|
+
|
|
29
|
+
// -------------------------------------------------------------
|
|
30
|
+
// STEP 0 — READ PACKAGE.JSON + ASK FOR MISSING FIELDS
|
|
31
|
+
// -------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
34
|
+
console.error(`${c.red}❌ package.json not found!${c.reset}`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
39
|
+
|
|
40
|
+
async function ensureMetadata() {
|
|
41
|
+
let { name, version, author } = pkg;
|
|
42
|
+
|
|
43
|
+
const questions = [];
|
|
44
|
+
|
|
45
|
+
if (!name || name.trim() === "") {
|
|
46
|
+
questions.push({
|
|
47
|
+
type: "text",
|
|
48
|
+
name: "name",
|
|
49
|
+
message: "Enter project name (required):",
|
|
50
|
+
validate: (x) => (x.trim() === "" ? "Name cannot be empty" : true)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!version || version.trim() === "") {
|
|
55
|
+
questions.push({
|
|
56
|
+
type: "text",
|
|
57
|
+
name: "version",
|
|
58
|
+
message: "Enter version (e.g., 1.0.0):",
|
|
59
|
+
validate: (x) => (x.trim() === "" ? "Version cannot be empty" : true)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!author || author.trim() === "") {
|
|
64
|
+
questions.push({
|
|
65
|
+
type: "text",
|
|
66
|
+
name: "author",
|
|
67
|
+
message: "Enter author name:",
|
|
68
|
+
validate: (x) => (x.trim() === "" ? "Author cannot be empty" : true)
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (questions.length > 0) {
|
|
73
|
+
const answers = await prompts(questions);
|
|
74
|
+
pkg = { ...pkg, ...answers };
|
|
75
|
+
|
|
76
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2));
|
|
77
|
+
console.log(`${c.green}✔ package.json updated with required fields.${c.reset}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return pkg;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const { name: projectName, version: projectVersion, author: projectAuthor } =
|
|
84
|
+
await ensureMetadata();
|
|
85
|
+
|
|
86
|
+
// -------------------------------------------------------------
|
|
87
|
+
// MAIN EXECUTION STARTS
|
|
88
|
+
// -------------------------------------------------------------
|
|
26
89
|
|
|
27
90
|
console.log(`${c.blue}\n📦 Starting production build...${c.reset}`);
|
|
28
91
|
|
|
29
92
|
try {
|
|
30
93
|
// Step 1: Run build
|
|
31
94
|
try {
|
|
95
|
+
console.log(`${c.green}\n✅ Starting Build Process...${c.reset}`);
|
|
32
96
|
execSync("npm run build", { stdio: "inherit" });
|
|
33
97
|
} catch (err) {
|
|
34
|
-
console.error(`${c.red}❌ Build process failed
|
|
98
|
+
console.error(`${c.red}❌ Build process failed.${c.reset}`);
|
|
35
99
|
process.exit(1);
|
|
36
100
|
}
|
|
37
101
|
|
|
@@ -41,40 +105,44 @@ try {
|
|
|
41
105
|
process.exit(1);
|
|
42
106
|
}
|
|
43
107
|
|
|
44
|
-
//
|
|
108
|
+
// -------------------------------------------------------------
|
|
109
|
+
// STEP 3 — ADD manifest.json INSIDE dist/
|
|
110
|
+
// -------------------------------------------------------------
|
|
111
|
+
const manifestPath = path.join(distFolder, "manifest.json");
|
|
112
|
+
|
|
113
|
+
const manifestContent = {
|
|
114
|
+
package_name: `com.${projectAuthor}.${projectName}`.toLowerCase().replace(/\s+/g, "-"),
|
|
115
|
+
version: projectVersion,
|
|
116
|
+
version_code: projectVersion.replace(/\./g, ""),
|
|
117
|
+
entry_point: "index.html",
|
|
118
|
+
permissions: [],
|
|
119
|
+
min_sdk_version: 1
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
fs.writeFileSync(manifestPath, JSON.stringify(manifestContent, null, 2));
|
|
123
|
+
|
|
124
|
+
console.log(`${c.green}✔ manifest.json created inside dist/${c.reset}`);
|
|
125
|
+
|
|
126
|
+
// -------------------------------------------------------------
|
|
127
|
+
// STEP 4 — Compress dist → dist.qpp
|
|
128
|
+
// -------------------------------------------------------------
|
|
45
129
|
await new Promise((resolve, reject) => {
|
|
46
130
|
const output = fs.createWriteStream(outputQpp);
|
|
47
131
|
const archive = archiver("zip", { zlib: { level: 9 } });
|
|
48
132
|
|
|
49
133
|
output.on("close", () => {
|
|
50
|
-
console.log(`${c.green}\n✅ Project
|
|
134
|
+
console.log(`${c.green}\n✅ Project compressed → dist.qpp${c.reset}`);
|
|
51
135
|
resolve();
|
|
52
136
|
});
|
|
53
137
|
|
|
54
|
-
|
|
55
|
-
console.error(`${c.red}❌ Failed to write output file: ${err.message}${c.reset}`);
|
|
56
|
-
reject(err);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
archive.on("warning", (err) => {
|
|
60
|
-
if (err.code === "ENOENT") {
|
|
61
|
-
console.warn(`${c.yellow}⚠️ Archive warning: ${err.message}${c.reset}`);
|
|
62
|
-
} else {
|
|
63
|
-
reject(err);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
archive.on("error", (err) => {
|
|
68
|
-
console.error(`${c.red}❌ Archiving failed: ${err.message}${c.reset}`);
|
|
69
|
-
reject(err);
|
|
70
|
-
});
|
|
138
|
+
archive.on("error", (err) => reject(err));
|
|
71
139
|
|
|
72
140
|
archive.pipe(output);
|
|
73
141
|
archive.directory(distFolder, false);
|
|
74
142
|
archive.finalize();
|
|
75
143
|
});
|
|
76
144
|
|
|
77
|
-
// Step
|
|
145
|
+
// Step 5: Remove dist folder
|
|
78
146
|
try {
|
|
79
147
|
await rm(distFolder, { recursive: true, force: true });
|
|
80
148
|
} catch (err) {
|
package/package.json
CHANGED
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quapp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
|
-
"author": "",
|
|
9
|
+
"author": "Quapp",
|
|
10
10
|
"bin": {
|
|
11
11
|
"quapp": "./bin/cli.js"
|
|
12
12
|
},
|
|
13
|
-
"license": "
|
|
14
|
-
"description": "",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"description": "A lightweight CLI tool that starts a Vite/Angular development server with LAN-accessible QR code and prepares your app for production with a simple build command.",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"archiver": "^7.0.1",
|
|
17
17
|
"open": "^10.1.2",
|
|
18
|
+
"prompts": "^2.4.2",
|
|
18
19
|
"qrcode-terminal": "^0.12.0"
|
|
19
|
-
}
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/Quapp-Store/Quapp/tree/main/packages/quapp"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"README.md",
|
|
27
|
+
"server.js",
|
|
28
|
+
"bin/cli.js",
|
|
29
|
+
"build.js"
|
|
30
|
+
]
|
|
20
31
|
}
|
package/server.js
CHANGED
|
@@ -88,7 +88,10 @@ const startVite = (port, attempt = 0) => {
|
|
|
88
88
|
process.exit(1);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
const vite = spawn(
|
|
91
|
+
const vite = spawn("npx", ["vite", ...viteArgs], {
|
|
92
|
+
stdio: "pipe",
|
|
93
|
+
shell: true,
|
|
94
|
+
});
|
|
92
95
|
|
|
93
96
|
vite.stdout.on("data", (data) => process.stdout.write(data));
|
|
94
97
|
vite.stderr.on("data", (data) => process.stderr.write(data));
|