@capgo/capacitor-pretty-toast 8.1.10 → 8.1.12
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/README.md +14 -0
- package/package.json +1 -1
- package/scripts/deploy-example-capgo.mjs +63 -38
package/README.md
CHANGED
|
@@ -18,6 +18,20 @@ This package keeps the familiar `toast.*` surface from `react-native-pretty-toas
|
|
|
18
18
|
|
|
19
19
|
## Install
|
|
20
20
|
|
|
21
|
+
You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Then use the following prompt:
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-pretty-toast` plugin in my project.
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:
|
|
34
|
+
|
|
21
35
|
```bash
|
|
22
36
|
bun add @capgo/capacitor-pretty-toast
|
|
23
37
|
```
|
package/package.json
CHANGED
|
@@ -1,71 +1,96 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
import { spawnSync } from 'node:child_process';
|
|
1
|
+
#!/usr/bin/env node
|
|
3
2
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
3
|
import { dirname, resolve } from 'node:path';
|
|
5
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { spawnSync } from 'node:child_process';
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
const repoRoot = resolve(
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const repoRoot = resolve(__dirname, '..');
|
|
9
9
|
const appDir = resolve(repoRoot, 'example-app');
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const rootPackageJson = JSON.parse(readFileSync(resolve(repoRoot, 'package.json'), 'utf8'));
|
|
11
|
+
const examplePackageJson = JSON.parse(readFileSync(resolve(appDir, 'package.json'), 'utf8'));
|
|
12
|
+
const configText = readFileSync(
|
|
13
|
+
existsSync(resolve(appDir, 'capacitor.config.ts'))
|
|
14
|
+
? resolve(appDir, 'capacitor.config.ts')
|
|
15
|
+
: resolve(appDir, 'capacitor.config.json'),
|
|
16
|
+
'utf8',
|
|
17
|
+
);
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`)
|
|
21
|
-
.join(' ');
|
|
19
|
+
function readConfigString(key, fallback) {
|
|
20
|
+
const match = configText.match(new RegExp(`['"]?${key}['"]?\\s*[:=]\\s*['"]([^'"]+)['"]`));
|
|
21
|
+
return match?.[1] ?? fallback;
|
|
22
|
+
}
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
const
|
|
24
|
+
function runCapgo(args, allowFailure = false) {
|
|
25
|
+
const token = process.env.CAPGO_TOKEN;
|
|
26
|
+
const fullArgs = ['@capgo/cli@latest', ...args];
|
|
27
|
+
if (token) {
|
|
28
|
+
fullArgs.push('--apikey', token);
|
|
29
|
+
}
|
|
30
|
+
const result = spawnSync('bunx', fullArgs, {
|
|
31
|
+
cwd: repoRoot,
|
|
32
|
+
stdio: 'inherit',
|
|
33
|
+
env: process.env,
|
|
34
|
+
});
|
|
35
|
+
if (!allowFailure && result.status !== 0) {
|
|
36
|
+
process.exit(result.status ?? 1);
|
|
37
|
+
}
|
|
38
|
+
return result.status ?? 1;
|
|
39
|
+
}
|
|
25
40
|
|
|
26
|
-
const appId = process.env.CAPGO_APP_ID;
|
|
41
|
+
const appId = process.env.CAPGO_APP_ID || readConfigString('appId');
|
|
42
|
+
const appName = process.env.CAPGO_APP_NAME || readConfigString('appName', rootPackageJson.name);
|
|
43
|
+
const webDir = process.env.CAPGO_WEB_DIR || readConfigString('webDir', 'dist');
|
|
44
|
+
const distDir = resolve(appDir, webDir);
|
|
27
45
|
const channel = process.env.CAPGO_CHANNEL || process.argv[2] || 'production';
|
|
28
46
|
const bundle = process.env.CAPGO_BUNDLE || rootPackageJson.version || examplePackageJson.version;
|
|
29
47
|
const comment =
|
|
30
48
|
process.env.CAPGO_COMMENT ||
|
|
31
49
|
(process.env.GITHUB_RUN_NUMBER
|
|
32
|
-
? `${
|
|
33
|
-
: `${
|
|
50
|
+
? `${appName} run ${process.env.GITHUB_RUN_NUMBER}`
|
|
51
|
+
: `${appName} ${bundle}`);
|
|
52
|
+
const iconPath = process.env.CAPGO_ICON || resolve(appDir, 'assets', 'capgo-icon.png');
|
|
53
|
+
|
|
54
|
+
if (!appId) {
|
|
55
|
+
console.error('Missing Capgo app id. Set CAPGO_APP_ID or example-app/capacitor.config.* appId.');
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
34
58
|
|
|
35
59
|
if (!existsSync(distDir)) {
|
|
36
|
-
console.error(
|
|
60
|
+
console.error(`Missing example app bundle at ${distDir}. Run bun run example:build first.`);
|
|
37
61
|
process.exit(1);
|
|
38
62
|
}
|
|
39
63
|
|
|
40
|
-
const
|
|
41
|
-
|
|
64
|
+
const appArgs = [appId, '--name', appName];
|
|
65
|
+
if (existsSync(iconPath)) {
|
|
66
|
+
appArgs.push('--icon', iconPath);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const setStatus = runCapgo(['app', 'set', ...appArgs], true);
|
|
70
|
+
if (setStatus !== 0) {
|
|
71
|
+
runCapgo(['app', 'add', ...appArgs]);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
console.log(`Deploying ${appId} to Capgo channel "${channel}"`);
|
|
75
|
+
|
|
76
|
+
runCapgo([
|
|
42
77
|
'bundle',
|
|
43
78
|
'upload',
|
|
44
|
-
|
|
79
|
+
appId,
|
|
45
80
|
'--bundle',
|
|
46
81
|
bundle,
|
|
47
82
|
'--path',
|
|
48
|
-
|
|
83
|
+
distDir,
|
|
49
84
|
'--channel',
|
|
50
85
|
channel,
|
|
51
86
|
'--package-json',
|
|
52
|
-
'package.json
|
|
87
|
+
'example-app/package.json,package.json',
|
|
53
88
|
'--node-modules',
|
|
54
|
-
'
|
|
89
|
+
'node_modules,example-app/node_modules',
|
|
55
90
|
'--delta',
|
|
56
91
|
'--no-key',
|
|
57
92
|
'--ignore-checksum-check',
|
|
58
93
|
'--version-exists-ok',
|
|
59
94
|
'--comment',
|
|
60
95
|
comment,
|
|
61
|
-
];
|
|
62
|
-
|
|
63
|
-
console.log(`Deploying ${appId ?? exampleName} to Capgo channel "${channel}"`);
|
|
64
|
-
|
|
65
|
-
const result = spawnSync('bunx', args, {
|
|
66
|
-
cwd: appDir,
|
|
67
|
-
stdio: 'inherit',
|
|
68
|
-
env: process.env,
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
process.exit(result.status ?? 1);
|
|
96
|
+
]);
|