uniwind-pro 1.0.0-beta.0
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/LICENSE +39 -0
- package/README.md +44 -0
- package/assets/banner-pro.png +0 -0
- package/package.json +30 -0
- package/pre/cli/commands.js +71 -0
- package/pre/cli/index.js +77 -0
- package/pre/cli/utils.js +68 -0
- package/pre/consts.js +7 -0
- package/pre/postinstall/index.js +39 -0
- package/pre/postinstall/install.js +97 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Uniwind Pro License Agreement
|
|
2
|
+
|
|
3
|
+
1. Ownership
|
|
4
|
+
All code and related assets included in this package remain the exclusive property of Codemask.
|
|
5
|
+
Licensed users are granted the right to integrate this package into their own software projects. All resulting applications, including their design, logic, and functionality, are the exclusive property of the license holder.
|
|
6
|
+
|
|
7
|
+
The underlying Uniwind Pro code and related assets remain the intellectual property of Codemask. Using Uniwind Pro in a project does not transfer ownership of this code or grant any right to extract, resell, or distribute it outside the licensed project.
|
|
8
|
+
|
|
9
|
+
2. License Grant
|
|
10
|
+
A valid and active Uniwind Pro license is required for any use of this software.
|
|
11
|
+
Each individual actively working with or accessing the Uniwind Pro codebase must have a valid license.
|
|
12
|
+
After project development is complete, only one active license is required to continue receiving updates or installing new versions of Uniwind Pro.
|
|
13
|
+
|
|
14
|
+
The license permits building, publishing, and distributing an unlimited number of commercial, internal, or open applications, provided that the license is active at the time of development and distribution.
|
|
15
|
+
|
|
16
|
+
3. Restrictions
|
|
17
|
+
You may not:
|
|
18
|
+
|
|
19
|
+
Share, publish, redistribute, or sub-license the package or any part of its source code.
|
|
20
|
+
|
|
21
|
+
Use the package, in whole or in part, to create or distribute a tool, library, or service that competes with Uniwind Pro or any related Codemask products.
|
|
22
|
+
|
|
23
|
+
Reverse-engineer, decompile, or modify the package for redistribution.
|
|
24
|
+
|
|
25
|
+
Expose or share CI/CD tokens, authentication credentials, or license keys publicly or with unauthorized parties.
|
|
26
|
+
|
|
27
|
+
4. Term and Termination
|
|
28
|
+
This license remains valid while your subscription or seat license is active and in compliance with these terms.
|
|
29
|
+
Codemask may terminate the license immediately if these terms are violated. Upon termination, you must cease using and distributing the software.
|
|
30
|
+
|
|
31
|
+
5. Warranty Disclaimer
|
|
32
|
+
The software is provided “as is,” without warranties of any kind, whether express or implied, including but not limited to fitness for a particular purpose or non-infringement.
|
|
33
|
+
In no event shall Codemask or its contributors be liable for any damages or losses arising from the use or inability to use this software.
|
|
34
|
+
|
|
35
|
+
6. General Terms
|
|
36
|
+
By installing or using Uniwind Pro, you acknowledge that you have read, understood, and agreed to these terms.
|
|
37
|
+
For licensing inquiries or additional permissions, contact support@uniwind.dev.
|
|
38
|
+
|
|
39
|
+
Copyright © 2025 Codemask. All rights reserved.
|
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<p align="center">
|
|
3
|
+
<a href="https://uniwind.dev/pricing"><img alt="uniwind" src="./assets/banner-pro.png"></a>
|
|
4
|
+
<a href="https://uniwind.dev/pricing" target="_blank">
|
|
5
|
+
<h1 align="center" style="color:red;">Uniwind Pro</h1>
|
|
6
|
+
<span>The fastest Tailwind bindings for React Native</span>
|
|
7
|
+
</a>
|
|
8
|
+
</p>
|
|
9
|
+
</div>
|
|
10
|
+
<br />
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
bun install uniwind-pro@beta react-native-nitro-modules react-native-reanimated react-native-worklets
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## CLI
|
|
19
|
+
|
|
20
|
+
Authorize and fetch your Pro package with:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
bunx uniwind-pro
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## Documentation
|
|
28
|
+
|
|
29
|
+
- [Start here](https://docs.uniwind.dev/quickstart)
|
|
30
|
+
- [Pro vs Free Version](https://docs.uniwind.dev/pro-version)
|
|
31
|
+
- [Migrate from Free Version](https://docs.uniwind.dev/pro/migrate-to-pro)
|
|
32
|
+
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
- 🚀 Best in class performance
|
|
36
|
+
- 🦄 Unistyles engine with no rerenders and Shadow Tree updates
|
|
37
|
+
- ⚛️ Tailwind to Reanimated translation layer. Use animations directly from `className`
|
|
38
|
+
- 🐄 Native platform updates from C++ with no extra dependencies (insets, dimensions, color scheme etc.)
|
|
39
|
+
- 🤓 Priority support
|
|
40
|
+
- 🔥 And... everything from [Uniwind Free version](https://docs.uniwind.dev/api/use-uniwind)
|
|
41
|
+
|
|
42
|
+
## License
|
|
43
|
+
|
|
44
|
+
See [LICENSE](LICENSE)
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "uniwind-pro",
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Uniwind Pro CLI",
|
|
6
|
+
"files": [
|
|
7
|
+
"pre/**/*",
|
|
8
|
+
"assets/**/*",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"postinstall": "node ./pre/postinstall/index.js"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"uniwind-pro": "./pre/cli/index.js"
|
|
17
|
+
},
|
|
18
|
+
"author": "Codemask",
|
|
19
|
+
"license": "UNLICENSED",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@zowe/secrets-for-zowe-sdk": "8.27.4",
|
|
22
|
+
"chalk": "5.6.2",
|
|
23
|
+
"eventsource": "4.0.0",
|
|
24
|
+
"figlet": "1.9.3",
|
|
25
|
+
"inquirer": "12.10.0",
|
|
26
|
+
"jwt-decode": "4.0.0",
|
|
27
|
+
"open": "10.2.0",
|
|
28
|
+
"tar": "7.5.2"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import open from 'open'
|
|
2
|
+
import chalk from 'chalk'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
import { dirname, join } from 'node:path'
|
|
5
|
+
import { spawn } from 'node:child_process'
|
|
6
|
+
import { keyring } from '@zowe/secrets-for-zowe-sdk'
|
|
7
|
+
import { SERVICE, UNIWIND_WEB_URL, SESSION_API_URL } from '../consts.js'
|
|
8
|
+
import { getTokenSSE } from './utils.js'
|
|
9
|
+
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
11
|
+
const __dirname = dirname(__filename)
|
|
12
|
+
const pkgJoin = join(__dirname, '../../package.json')
|
|
13
|
+
|
|
14
|
+
export const login = async () => {
|
|
15
|
+
const res = await fetch(`${SESSION_API_URL}/session`, { method: 'POST' })
|
|
16
|
+
const { sessionId, authUrl } = await res.json()
|
|
17
|
+
|
|
18
|
+
open(authUrl)
|
|
19
|
+
|
|
20
|
+
console.log(chalk.dim('\nWaiting for authorization response...'))
|
|
21
|
+
|
|
22
|
+
const { token, handle } = await getTokenSSE(sessionId)
|
|
23
|
+
|
|
24
|
+
await keyring.setPassword(SERVICE, handle, token)
|
|
25
|
+
|
|
26
|
+
console.log(chalk.green(`\n🔑 Logged in as @${handle}`))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const buy = async () => {
|
|
30
|
+
console.log(chalk.green('Opening Uniwind Pro purchase page...'))
|
|
31
|
+
|
|
32
|
+
await open(`${UNIWIND_WEB_URL}/pricing`)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const account = async () => {
|
|
36
|
+
console.log(chalk.green('Opening Uniwind Pro dashboard...'))
|
|
37
|
+
|
|
38
|
+
await open(`${UNIWIND_WEB_URL}/login`)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const postinstall = async () => {
|
|
42
|
+
const child = spawn('npm', ['run', 'postinstall'], {
|
|
43
|
+
cwd: dirname(pkgJoin),
|
|
44
|
+
stdio: 'inherit',
|
|
45
|
+
shell: true,
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
child.on('close', (code) => {
|
|
49
|
+
if (code === 0) {
|
|
50
|
+
console.log(chalk.green('Uniwind Pro installed successfully'))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
process.exit(code)
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const logout = async () => {
|
|
58
|
+
const maybeCredentials = await keyring.findCredentials(SERVICE)
|
|
59
|
+
|
|
60
|
+
if (maybeCredentials.length === 0) {
|
|
61
|
+
console.log(chalk.yellow('No credentials found.'))
|
|
62
|
+
|
|
63
|
+
return Promise.resolve()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
for (const { account } of maybeCredentials) {
|
|
67
|
+
await keyring.deletePassword(SERVICE, account)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.log(chalk.yellow('\n🔑 Signed out'))
|
|
71
|
+
}
|
package/pre/cli/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import figlet from 'figlet'
|
|
4
|
+
import inquirer from 'inquirer'
|
|
5
|
+
import chalk from 'chalk'
|
|
6
|
+
import { login, buy, logout, account, postinstall } from './commands.js'
|
|
7
|
+
import { getSesionMetadata } from './utils.js'
|
|
8
|
+
|
|
9
|
+
async function interactiveMode() {
|
|
10
|
+
const banner = figlet.textSync('Uniwind Pro')
|
|
11
|
+
|
|
12
|
+
console.log(`\n${banner}\n`)
|
|
13
|
+
|
|
14
|
+
let shouldExit = false
|
|
15
|
+
|
|
16
|
+
while (!shouldExit) {
|
|
17
|
+
const session = await getSesionMetadata()
|
|
18
|
+
const choices = session
|
|
19
|
+
? [
|
|
20
|
+
new inquirer.Separator(chalk.green(` Your session is valid for the next ${session.expiresAt}`)),
|
|
21
|
+
new inquirer.Separator(chalk.dim('────────────────────────────────────────────')),
|
|
22
|
+
{ name: chalk.whiteBright('Manage your account'), value: 'account' },
|
|
23
|
+
{ name: chalk.whiteBright('Install Uniwind Pro'), value: 'postinstall' },
|
|
24
|
+
{ name: chalk.whiteBright('Logout'), value: 'logout' },
|
|
25
|
+
{ name: chalk.whiteBright('Exit'), value: 'exit' }
|
|
26
|
+
]
|
|
27
|
+
: [
|
|
28
|
+
{ name: chalk.whiteBright('Login with Github'), value: 'login' },
|
|
29
|
+
{ name: chalk.whiteBright('Buy Uniwind Pro'), value: 'buy' },
|
|
30
|
+
{ name: chalk.whiteBright('Exit'), value: 'exit' }
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
const message = session
|
|
34
|
+
? chalk.white(`Hello @${session.handle}, what would you like to do?`)
|
|
35
|
+
: chalk.white('What would you like to do?')
|
|
36
|
+
|
|
37
|
+
const { action } = await inquirer.prompt([
|
|
38
|
+
{
|
|
39
|
+
type: 'list',
|
|
40
|
+
name: 'action',
|
|
41
|
+
message,
|
|
42
|
+
choices
|
|
43
|
+
}
|
|
44
|
+
])
|
|
45
|
+
|
|
46
|
+
switch (action) {
|
|
47
|
+
case 'login':
|
|
48
|
+
await login()
|
|
49
|
+
break
|
|
50
|
+
case 'account':
|
|
51
|
+
await account()
|
|
52
|
+
break
|
|
53
|
+
case 'postinstall':
|
|
54
|
+
await postinstall()
|
|
55
|
+
break
|
|
56
|
+
case 'buy':
|
|
57
|
+
await buy()
|
|
58
|
+
break
|
|
59
|
+
case 'logout':
|
|
60
|
+
await logout()
|
|
61
|
+
break
|
|
62
|
+
case 'exit':
|
|
63
|
+
shouldExit = true
|
|
64
|
+
console.log(chalk.dim('\nSession closed\n'))
|
|
65
|
+
break
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!shouldExit) {
|
|
69
|
+
console.log()
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interactiveMode().catch((error) => {
|
|
75
|
+
console.error(chalk.red(`\nAn error occurred: ${error.message}`))
|
|
76
|
+
process.exit(1)
|
|
77
|
+
})
|
package/pre/cli/utils.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jwtDecode } from 'jwt-decode'
|
|
2
|
+
import { keyring } from '@zowe/secrets-for-zowe-sdk'
|
|
3
|
+
import { EventSource } from 'eventsource'
|
|
4
|
+
import { SERVICE, SESSION_API_URL } from '../consts.js'
|
|
5
|
+
|
|
6
|
+
export const getSesionMetadata = async () => {
|
|
7
|
+
const credentials = await keyring.findCredentials(SERVICE)
|
|
8
|
+
|
|
9
|
+
if (credentials.length === 0) {
|
|
10
|
+
return null
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const uniwindCredentials = credentials.at(0)
|
|
14
|
+
const decoded = jwtDecode(uniwindCredentials.password)
|
|
15
|
+
const exp = decoded.exp
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
handle: uniwindCredentials.account,
|
|
19
|
+
expiresAt: getExpirationLabel(exp)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const getExpirationLabel = (expiresAt) => {
|
|
24
|
+
const expiryDate = new Date(expiresAt * 1000)
|
|
25
|
+
const now = new Date()
|
|
26
|
+
const diffMs = expiryDate.getTime() - now.getTime()
|
|
27
|
+
|
|
28
|
+
if (diffMs <= 0) {
|
|
29
|
+
return 'expired'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const minutes = Math.floor(diffMs / 1000 / 60)
|
|
33
|
+
const hours = Math.floor(minutes / 60)
|
|
34
|
+
const days = Math.floor(hours / 24)
|
|
35
|
+
|
|
36
|
+
if (hours >= 48) {
|
|
37
|
+
return `${days} days`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (hours >= 1) {
|
|
41
|
+
return `${hours} hour${hours > 1 ? 's' : ''}`
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return `${minutes} minute${minutes !== 1 ? 's' : ''}`
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const getTokenSSE = async (sessionId) => {
|
|
48
|
+
return await new Promise((resolve, reject) => {
|
|
49
|
+
const es = new EventSource(`${SESSION_API_URL}/session/ping?state=${sessionId}`)
|
|
50
|
+
|
|
51
|
+
es.addEventListener('success', (event) => {
|
|
52
|
+
const data = JSON.parse(event.data)
|
|
53
|
+
|
|
54
|
+
es.close()
|
|
55
|
+
resolve({ token: data.token, handle: data.handle })
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
es.addEventListener('abort', () => {
|
|
59
|
+
es.close()
|
|
60
|
+
reject(new Error('You have no permission to install Uniwind Pro or your session has expired.'))
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
es.onerror = (err) => {
|
|
64
|
+
es.close()
|
|
65
|
+
reject(err)
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
}
|
package/pre/consts.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const SERVICE = 'UniwindPro'
|
|
2
|
+
export const UNIWIND_AUTH_TOKEN = 'UNIWIND_AUTH_TOKEN'
|
|
3
|
+
export const HELP_EMAIL = 'support@uniwind.dev'
|
|
4
|
+
export const UNIWIND_WEB_URL = 'https://uniwind.dev'
|
|
5
|
+
export const BASE_URL = 'https://cdn.uniwind.dev'
|
|
6
|
+
export const INSTALLATION_URL = `${BASE_URL}/uniwind-pro`
|
|
7
|
+
export const SESSION_API_URL = `${BASE_URL}/github`
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Chalk } from 'chalk'
|
|
2
|
+
import { keyring } from '@zowe/secrets-for-zowe-sdk'
|
|
3
|
+
import { UNIWIND_AUTH_TOKEN, SERVICE, UNIWIND_WEB_URL, HELP_EMAIL } from '../consts.js'
|
|
4
|
+
import { downloadFromCI, downloadFromCLI } from './install.js'
|
|
5
|
+
|
|
6
|
+
const chalk = new Chalk({ level: 3 })
|
|
7
|
+
|
|
8
|
+
const main = async () => {
|
|
9
|
+
const maybeCICDToken = process.env[UNIWIND_AUTH_TOKEN]
|
|
10
|
+
|
|
11
|
+
if (maybeCICDToken) {
|
|
12
|
+
return await downloadFromCI(maybeCICDToken)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const matchingCredentials = await keyring.findCredentials(SERVICE)
|
|
16
|
+
|
|
17
|
+
if (matchingCredentials.length !== 0) {
|
|
18
|
+
return await downloadFromCLI(matchingCredentials.at(0))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
throw new Error('No credentials found')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
main().catch((error) => {
|
|
25
|
+
console.log(chalk.red.bold("Access denied: You don't have permission to install this package.\n"))
|
|
26
|
+
console.log(
|
|
27
|
+
chalk.dim.red(
|
|
28
|
+
`To get a license, visit ${chalk.bold.underline(UNIWIND_WEB_URL)}.\n` +
|
|
29
|
+
`If you already have one, run cli via:\n\n` +
|
|
30
|
+
`${chalk.bold('uniwind-pro')}\n\n` +
|
|
31
|
+
`For CI/CD environments, ensure the ${chalk.bold.underline(UNIWIND_AUTH_TOKEN)} environment variable is set.\n\n` +
|
|
32
|
+
`Need help? Contact ${chalk.bold.underline(HELP_EMAIL)} for assistance.\n`
|
|
33
|
+
)
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
console.log(chalk.dim.gray(error.message))
|
|
37
|
+
|
|
38
|
+
process.exit(1)
|
|
39
|
+
})
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import { readFileSync, mkdirSync, readdirSync, cpSync, rmSync } from 'node:fs'
|
|
3
|
+
import { keyring } from '@zowe/secrets-for-zowe-sdk'
|
|
4
|
+
import { join, dirname } from 'node:path'
|
|
5
|
+
import { fileURLToPath } from 'node:url'
|
|
6
|
+
import { pipeline } from 'node:stream'
|
|
7
|
+
import { promisify } from 'node:util'
|
|
8
|
+
import { x as extract } from 'tar'
|
|
9
|
+
import { INSTALLATION_URL, SERVICE } from '../consts.js'
|
|
10
|
+
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
12
|
+
const pkgPath = join(__dirname, '../../package.json')
|
|
13
|
+
const rootPkgPath = join(__dirname, '../../../../package.json')
|
|
14
|
+
const streamPipeline = promisify(pipeline)
|
|
15
|
+
|
|
16
|
+
const getVersion = () => {
|
|
17
|
+
try {
|
|
18
|
+
const packageVersion = readFileSync(pkgPath, 'utf8')
|
|
19
|
+
|
|
20
|
+
return JSON.parse(packageVersion).version
|
|
21
|
+
} catch (e) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`Couldn\'t find package.json file under ${pkgPath} or missing package version.`
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const getProjectName = () => {
|
|
29
|
+
try {
|
|
30
|
+
const packageJson = readFileSync(rootPkgPath, 'utf8')
|
|
31
|
+
const parsedPackageJSON = JSON.parse(packageJson)
|
|
32
|
+
|
|
33
|
+
return parsedPackageJSON.name
|
|
34
|
+
} catch (e) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`Couldn\'t find package.json file under ${pkgPath} or missing package version.`
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const downloadFromCI = async (licenseUUID) => {
|
|
42
|
+
const packageVersion = getVersion()
|
|
43
|
+
const cdnUrl = `${INSTALLATION_URL}/ci/${packageVersion}/${licenseUUID}`
|
|
44
|
+
const response = await fetch(cdnUrl)
|
|
45
|
+
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
throw new Error(`Download failed: ${response.status} ${response.statusText}`)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return await install(response.body)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const downloadFromCLI = async ({ account: handle, password: token }) => {
|
|
54
|
+
const packageVersion = getVersion()
|
|
55
|
+
const projectName = getProjectName()
|
|
56
|
+
|
|
57
|
+
console.log(chalk.dim(`Fetching v${packageVersion} for project "${projectName}"...\n`))
|
|
58
|
+
|
|
59
|
+
const cdnUrl = `${INSTALLATION_URL}/cli/${handle}/${projectName}/${packageVersion}/${token}`
|
|
60
|
+
const response = await fetch(cdnUrl)
|
|
61
|
+
|
|
62
|
+
if (response.ok) {
|
|
63
|
+
return await install(response.body)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (response.status === 401) {
|
|
67
|
+
await keyring.deleteCredentials(SERVICE)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
const body = await response.json()
|
|
72
|
+
|
|
73
|
+
throw new Error(`Download failed: ${response.status} ${body.error}`)
|
|
74
|
+
} catch (e) {
|
|
75
|
+
throw new Error(`Download failed: ${response.status} ${response.statusText}`)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const install = async (stream) => {
|
|
80
|
+
const TMP_DIR = join(__dirname, '../../_package')
|
|
81
|
+
|
|
82
|
+
mkdirSync(TMP_DIR, { recursive: true })
|
|
83
|
+
|
|
84
|
+
await streamPipeline(
|
|
85
|
+
stream,
|
|
86
|
+
extract({
|
|
87
|
+
cwd: TMP_DIR,
|
|
88
|
+
strip: 1,
|
|
89
|
+
})
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
for (const file of readdirSync(TMP_DIR)) {
|
|
93
|
+
cpSync(join(TMP_DIR, file), join(__dirname, '../../', file), { recursive: true })
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
rmSync(TMP_DIR, { recursive: true, force: true })
|
|
97
|
+
}
|