-
Notifications
You must be signed in to change notification settings - Fork 0
/
link-dependecy.js
executable file
·87 lines (79 loc) · 1.86 KB
/
link-dependecy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const cli = require('cli');
var colors = {
red: '\x1b[31m',
green: '\x1b[32m',
reset: '\x1b[0m',
};
cli.parse({
ios: ['i', 'path to xcframework folder', 'file'],
android: ['a', 'path to aar file', 'file'],
});
function copyRecursiveSync(src, dest) {
var exists = fs.existsSync(src);
var stats = exists && fs.statSync(src);
var isDirectory = exists && stats.isDirectory();
if (isDirectory) {
fs.mkdirSync(dest);
fs.readdirSync(src).forEach(function (childItemName) {
copyRecursiveSync(
path.join(src, childItemName),
path.join(dest, childItemName)
);
});
} else {
fs.copyFileSync(src, dest);
}
}
function WriteFileFolder(key, from, output, neededext, isFolder) {
if (!from.endsWith(neededext)) {
console.error(
colors.red,
key +
' argument needs to be set to a ' +
neededext +
' ' +
(isFolder ? 'folder' : 'file'),
colors.reset
);
return;
} else if (!fs.existsSync(from)) {
console.error(
colors.red,
key + ' argument ' + path.resolve(from) + ' does not exist',
colors.reset
);
return;
}
if (fs.existsSync(output)) {
fs.rmSync(output, { recursive: isFolder });
}
var copyFile =
typeof fs.cpSync === 'function' ? fs.cpSync : copyRecursiveSync;
copyFile(from, output, { recursive: isFolder });
console.log(
colors.green,
'Successfully linked ' + key + ' dependency',
colors.reset
);
}
if (cli.options.ios) {
WriteFileFolder(
'IOS',
cli.options.ios,
`${__dirname}/Frameworks/ipworks3ds_sdk.xcframework`,
'.xcframework',
true
);
}
if (cli.options.android) {
WriteFileFolder(
'Android',
cli.options.android,
`${__dirname}/android/libs/ipworks3ds_sdk_deploy.aar`,
'.aar',
false
);
}