uniwind-pro 1.0.0-rc.7 → 1.0.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/README.md +5 -2
- package/package.json +1 -1
- package/pre/cli/commands.js +49 -1
- package/pre/cli/index.js +5 -1
- package/pre/postinstall/checkLatestVersion.js +19 -0
- package/pre/postinstall/install.js +56 -3
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
14
|
```sh
|
|
15
|
-
bun install uniwind-pro@
|
|
15
|
+
bun install uniwind-pro@latest react-native-nitro-modules react-native-reanimated react-native-worklets
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## CLI
|
|
@@ -23,10 +23,13 @@ Authorize and fetch your Pro package with:
|
|
|
23
23
|
bunx uniwind-pro
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
## Demo
|
|
27
|
+
|
|
28
|
+
Check out the [Uniwind Pro Demo](https://github.com/uni-stack/uniwind-pro-demo) — a complete Expo SDK 54 / React Native 0.83.5 app showcasing the C++ engine, ShadowTree updates, and native transitions. Clone it and run on your iOS simulator.
|
|
29
|
+
|
|
26
30
|
## Get Started
|
|
27
31
|
- [Purchase a license](https://docs.uniwind.dev/pro/get-license)
|
|
28
32
|
|
|
29
|
-
|
|
30
33
|
## Documentation
|
|
31
34
|
|
|
32
35
|
- [Start here](https://docs.uniwind.dev/quickstart)
|
package/package.json
CHANGED
package/pre/cli/commands.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url'
|
|
|
4
4
|
import { dirname, join } from 'node:path'
|
|
5
5
|
import { spawn } from 'node:child_process'
|
|
6
6
|
import { keyring } from '@zowe/secrets-for-zowe-sdk'
|
|
7
|
-
import { SERVICE, UNIWIND_WEB_URL, SESSION_API_URL } from '../consts.js'
|
|
7
|
+
import { SERVICE, UNIWIND_WEB_URL, SESSION_API_URL, BASE_URL } from '../consts.js'
|
|
8
8
|
import { getTokenSSE } from './utils.js'
|
|
9
9
|
|
|
10
10
|
const __filename = fileURLToPath(import.meta.url)
|
|
@@ -54,6 +54,54 @@ export const postinstall = async () => {
|
|
|
54
54
|
})
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
export const usage = async () => {
|
|
58
|
+
const maybeCredentials = await keyring.findCredentials(SERVICE)
|
|
59
|
+
|
|
60
|
+
if (maybeCredentials.length === 0) {
|
|
61
|
+
console.log(chalk.yellow('Not logged in. Run: uniwind-pro login'))
|
|
62
|
+
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const { password: token } = maybeCredentials.at(0)
|
|
67
|
+
const response = await fetch(`${BASE_URL}/usage`, {
|
|
68
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
if (!response.ok) {
|
|
72
|
+
throw new Error(`Failed to fetch usage: ${response.status} ${response.statusText}`)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const data = await response.json()
|
|
76
|
+
|
|
77
|
+
if (!data.licenseKeys || data.licenseKeys.length === 0) {
|
|
78
|
+
console.log(chalk.yellow('\nNo active license keys found.'))
|
|
79
|
+
console.log(chalk.gray('Run: uniwind-pro buy'))
|
|
80
|
+
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log(chalk.white('\nDownload Usage\n'))
|
|
85
|
+
|
|
86
|
+
const BAR_WIDTH = 30
|
|
87
|
+
|
|
88
|
+
for (const key of data.licenseKeys) {
|
|
89
|
+
const filled = Math.round(key.used * BAR_WIDTH)
|
|
90
|
+
const empty = BAR_WIDTH - filled
|
|
91
|
+
const color = key.used <= 0.5 ? chalk.green : key.used <= 0.75 ? chalk.yellow : chalk.red
|
|
92
|
+
const bar = color('\u2588'.repeat(filled)) + chalk.white('\u2591'.repeat(empty))
|
|
93
|
+
const pct = Math.round(key.used * 100)
|
|
94
|
+
|
|
95
|
+
const resetDate = new Date((key.periodEnd + 86400) * 1000)
|
|
96
|
+
const month = resetDate.toLocaleString('en-US', { month: 'short', timeZone: 'UTC' })
|
|
97
|
+
const day = resetDate.getUTCDate()
|
|
98
|
+
|
|
99
|
+
console.log(chalk.bold(key.label))
|
|
100
|
+
console.log(`${bar} ${pct}% used (${key.currentDownloads}/${key.downloadLimit})`)
|
|
101
|
+
console.log(chalk.gray(`Resets ${month} ${day}\n`))
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
57
105
|
export const logout = async () => {
|
|
58
106
|
const maybeCredentials = await keyring.findCredentials(SERVICE)
|
|
59
107
|
|
package/pre/cli/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import figlet from 'figlet'
|
|
4
4
|
import inquirer from 'inquirer'
|
|
5
5
|
import chalk from 'chalk'
|
|
6
|
-
import { login, buy, logout, account, postinstall } from './commands.js'
|
|
6
|
+
import { login, buy, logout, account, postinstall, usage } from './commands.js'
|
|
7
7
|
import { getSesionMetadata } from './utils.js'
|
|
8
8
|
|
|
9
9
|
async function interactiveMode() {
|
|
@@ -23,6 +23,7 @@ async function interactiveMode() {
|
|
|
23
23
|
new inquirer.Separator(chalk.gray('────────────────────────────────────────────')),
|
|
24
24
|
{ name: 'Manage your account', value: 'account' },
|
|
25
25
|
{ name: 'Install Uniwind Pro', value: 'postinstall' },
|
|
26
|
+
{ name: 'Download usage', value: 'usage' },
|
|
26
27
|
{ name: 'Logout', value: 'logout' },
|
|
27
28
|
{ name: chalk.gray('Exit'), value: 'exit' },
|
|
28
29
|
]
|
|
@@ -55,6 +56,9 @@ async function interactiveMode() {
|
|
|
55
56
|
case 'postinstall':
|
|
56
57
|
await postinstall()
|
|
57
58
|
break
|
|
59
|
+
case 'usage':
|
|
60
|
+
await usage()
|
|
61
|
+
break
|
|
58
62
|
case 'buy':
|
|
59
63
|
await buy()
|
|
60
64
|
break
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const NPM_REGISTRY = 'https://registry.npmjs.org'
|
|
2
|
+
|
|
3
|
+
export const checkLatestVersion = async (packageName, currentVersion) => {
|
|
4
|
+
try {
|
|
5
|
+
const response = await fetch(`${NPM_REGISTRY}/${packageName}/latest`, {
|
|
6
|
+
signal: AbortSignal.timeout(3000),
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
if (!response.ok) {
|
|
10
|
+
return null
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { version: latest } = await response.json()
|
|
14
|
+
|
|
15
|
+
return { latest, isOutdated: latest !== currentVersion && !(currentVersion > latest) }
|
|
16
|
+
} catch {
|
|
17
|
+
return null
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -5,19 +5,32 @@ import { fileURLToPath } from 'node:url'
|
|
|
5
5
|
import { pipeline } from 'node:stream'
|
|
6
6
|
import { promisify } from 'node:util'
|
|
7
7
|
import { x as extract } from 'tar'
|
|
8
|
-
import { INSTALLATION_URL, SERVICE } from '../consts.js'
|
|
8
|
+
import { INSTALLATION_URL, SERVICE, HELP_EMAIL } from '../consts.js'
|
|
9
9
|
import {
|
|
10
10
|
copyDirectoryContents,
|
|
11
11
|
enforceCachePolicy,
|
|
12
12
|
restoreFromCache,
|
|
13
13
|
saveToCache,
|
|
14
14
|
} from './cache.js'
|
|
15
|
+
import { checkLatestVersion } from './checkLatestVersion.js'
|
|
15
16
|
|
|
16
17
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
17
18
|
const PKG_ROOT = join(__dirname, '../../')
|
|
18
19
|
const pkgPath = join(PKG_ROOT, 'package.json')
|
|
19
20
|
const streamPipeline = promisify(pipeline)
|
|
20
21
|
|
|
22
|
+
const warnIfOutdated = async (versionCheck, currentVersion) => {
|
|
23
|
+
const result = await versionCheck
|
|
24
|
+
|
|
25
|
+
if (result?.isOutdated) {
|
|
26
|
+
console.log(
|
|
27
|
+
chalk.yellow(
|
|
28
|
+
`\nA newer version of Uniwind Pro is available: ${result.latest} (current: ${currentVersion})\n`
|
|
29
|
+
)
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
21
34
|
const getVersion = () => {
|
|
22
35
|
try {
|
|
23
36
|
const packageVersion = readFileSync(pkgPath, 'utf8')
|
|
@@ -104,11 +117,13 @@ const getProjectName = () => {
|
|
|
104
117
|
|
|
105
118
|
export const downloadFromCI = async (licenseUUID) => {
|
|
106
119
|
const packageVersion = getVersion()
|
|
120
|
+
const versionCheck = checkLatestVersion('uniwind-pro', packageVersion)
|
|
107
121
|
|
|
108
122
|
enforceCachePolicy(packageVersion)
|
|
109
123
|
|
|
110
124
|
if (restoreFromCache(packageVersion, PKG_ROOT)) {
|
|
111
125
|
console.log(chalk.gray(`Using cached v${packageVersion} package...\n`))
|
|
126
|
+
await warnIfOutdated(versionCheck, packageVersion)
|
|
112
127
|
|
|
113
128
|
return
|
|
114
129
|
}
|
|
@@ -116,21 +131,40 @@ export const downloadFromCI = async (licenseUUID) => {
|
|
|
116
131
|
const cdnUrl = `${INSTALLATION_URL}/ci/${packageVersion}/${licenseUUID}`
|
|
117
132
|
const response = await fetch(cdnUrl)
|
|
118
133
|
|
|
134
|
+
if (response.status === 429) {
|
|
135
|
+
const body = await response.json().catch(() => ({}))
|
|
136
|
+
|
|
137
|
+
console.log(chalk.red.bold('\nDownload limit reached.\n'))
|
|
138
|
+
console.log(chalk.red(body.error || 'You have exhausted your monthly download quota.'))
|
|
139
|
+
console.log(chalk.yellow(`\nContact ${HELP_EMAIL} if you need assistance.\n`))
|
|
140
|
+
|
|
141
|
+
process.exit(1)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (response.status === 404) {
|
|
145
|
+
console.log(chalk.red(`\nPackage version ${packageVersion} not found on CDN.\n`))
|
|
146
|
+
|
|
147
|
+
process.exit(1)
|
|
148
|
+
}
|
|
149
|
+
|
|
119
150
|
if (!response.ok) {
|
|
120
151
|
throw new Error(`Download failed: ${response.status} ${response.statusText}`)
|
|
121
152
|
}
|
|
122
153
|
|
|
123
|
-
|
|
154
|
+
await install(response.body, packageVersion)
|
|
155
|
+
await warnIfOutdated(versionCheck, packageVersion)
|
|
124
156
|
}
|
|
125
157
|
|
|
126
158
|
export const downloadFromCLI = async ({ account: handle, password: token }) => {
|
|
127
159
|
const packageVersion = getVersion()
|
|
128
160
|
const projectName = getProjectName()
|
|
161
|
+
const versionCheck = checkLatestVersion('uniwind-pro', packageVersion)
|
|
129
162
|
|
|
130
163
|
enforceCachePolicy(packageVersion)
|
|
131
164
|
|
|
132
165
|
if (restoreFromCache(packageVersion, PKG_ROOT)) {
|
|
133
166
|
console.log(chalk.gray(`Using cached v${packageVersion} for project "${projectName}".\n`))
|
|
167
|
+
await warnIfOutdated(versionCheck, packageVersion)
|
|
134
168
|
|
|
135
169
|
return
|
|
136
170
|
}
|
|
@@ -141,7 +175,26 @@ export const downloadFromCLI = async ({ account: handle, password: token }) => {
|
|
|
141
175
|
const response = await fetch(cdnUrl)
|
|
142
176
|
|
|
143
177
|
if (response.ok) {
|
|
144
|
-
|
|
178
|
+
await install(response.body, packageVersion)
|
|
179
|
+
await warnIfOutdated(versionCheck, packageVersion)
|
|
180
|
+
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (response.status === 429) {
|
|
185
|
+
const body = await response.json().catch(() => ({}))
|
|
186
|
+
|
|
187
|
+
console.log(chalk.red.bold('\nDownload limit reached.\n'))
|
|
188
|
+
console.log(chalk.red(body.error || 'You have exhausted your monthly download quota.'))
|
|
189
|
+
console.log(chalk.yellow(`\nContact ${HELP_EMAIL} if you need assistance.\n`))
|
|
190
|
+
|
|
191
|
+
process.exit(1)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (response.status === 404) {
|
|
195
|
+
console.log(chalk.red(`\nPackage version ${packageVersion} not found on CDN.\n`))
|
|
196
|
+
|
|
197
|
+
process.exit(1)
|
|
145
198
|
}
|
|
146
199
|
|
|
147
200
|
if (response.status === 401) {
|