appmachine 0.0.9 → 0.1.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/package.json +4 -2
- package/scripts/install.js +54 -0
- package/bin/install.js +0 -55
- /package/{README.md → .github/README.md} +0 -0
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appmachine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Native iOS/Android shell generator via GitHub Actions",
|
|
5
5
|
"author": "Max Matinpalo",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"
|
|
7
|
+
"scripts": {
|
|
8
|
+
"postinstall": "node ./scripts/install.js"
|
|
9
|
+
}
|
|
8
10
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
|
|
10
|
+
// 1. Log error and exit process
|
|
11
|
+
function die(msg) {
|
|
12
|
+
console.error("❌ " + msg);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 2. Recursive copy that skips existing files to protect user modifications
|
|
17
|
+
function copy(s, d) {
|
|
18
|
+
const stat = fs.statSync(s);
|
|
19
|
+
|
|
20
|
+
if (stat.isDirectory()) {
|
|
21
|
+
if (!fs.existsSync(d)) fs.mkdirSync(d, { recursive: true });
|
|
22
|
+
fs.readdirSync(s).forEach(f => copy(path.join(s, f), path.join(d, f)));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!fs.existsSync(d)) fs.copyFileSync(s, d);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// 3. Main installer logic
|
|
30
|
+
function install() {
|
|
31
|
+
// INIT_CWD is set by npm/pnpm during postinstall to point to the actual project root
|
|
32
|
+
const root = process.env.INIT_CWD || process.cwd();
|
|
33
|
+
const src = path.join(__dirname, "../src");
|
|
34
|
+
const dest = path.join(root, ".github/workflows");
|
|
35
|
+
const temp = path.join(__dirname, "../template");
|
|
36
|
+
const mach = path.join(root, "appmachine");
|
|
37
|
+
|
|
38
|
+
// 4. Overwrite workflow files to keep CI/CD pipelines updated with the package version
|
|
39
|
+
if (fs.existsSync(src)) {
|
|
40
|
+
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
|
|
41
|
+
fs.readdirSync(src).forEach(f => {
|
|
42
|
+
if (f.endsWith(".yml")) fs.copyFileSync(path.join(src, f), path.join(dest, f));
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 5. Initialize the appmachine directory if it doesn't exist
|
|
47
|
+
if (fs.existsSync(temp)) copy(temp, mach);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
install();
|
|
52
|
+
} catch (err) {
|
|
53
|
+
die(err.message || "Install failed");
|
|
54
|
+
}
|
package/bin/install.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import { fileURLToPath } from 'url';
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = path.dirname(__filename);
|
|
10
|
-
|
|
11
|
-
function die(msg) {
|
|
12
|
-
console.error("❌ " + msg);
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Recursively copies files or directories from source (s) to destination (d)
|
|
17
|
-
function copy(s, d) {
|
|
18
|
-
const stat = fs.statSync(s);
|
|
19
|
-
|
|
20
|
-
// If it's a folder, ensure destination exists and copy all children
|
|
21
|
-
if (stat.isDirectory()) {
|
|
22
|
-
if (!fs.existsSync(d)) fs.mkdirSync(d, { recursive: true });
|
|
23
|
-
fs.readdirSync(s).forEach(f => copy(path.join(s, f), path.join(d, f)));
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Otherwise, just copy the file
|
|
28
|
-
fs.copyFileSync(s, d);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Main setup: moves GitHub workflows and AppMachine templates into the project root
|
|
32
|
-
function install() {
|
|
33
|
-
const root = process.cwd();
|
|
34
|
-
const src = path.join(__dirname, '../src');
|
|
35
|
-
const dest = path.join(root, '.github/workflows');
|
|
36
|
-
const temp = path.join(__dirname, '../template');
|
|
37
|
-
const mach = path.join(root, 'appmachine');
|
|
38
|
-
|
|
39
|
-
// 1. Copy all .yml workflow files to .github/workflows
|
|
40
|
-
if (fs.existsSync(src)) {
|
|
41
|
-
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
|
|
42
|
-
fs.readdirSync(src).forEach(f => {
|
|
43
|
-
if (f.endsWith('.yml')) fs.copyFileSync(path.join(src, f), path.join(dest, f));
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// 2. Recursively copy the template folder to /appmachine
|
|
48
|
-
if (fs.existsSync(temp)) copy(temp, mach);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
install();
|
|
53
|
-
} catch (err) {
|
|
54
|
-
die(err.message || "Install failed");
|
|
55
|
-
}
|
|
File without changes
|