uniwind-pro 1.0.0-beta.1 → 1.0.0-beta.11

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 CHANGED
@@ -23,12 +23,16 @@ Authorize and fetch your Pro package with:
23
23
  bunx uniwind-pro
24
24
  ```
25
25
 
26
+ ## Get Started
27
+ - [Purchase a license](https://docs.uniwind.dev/pro/get-license)
28
+
26
29
 
27
30
  ## Documentation
28
31
 
29
32
  - [Start here](https://docs.uniwind.dev/quickstart)
30
33
  - [Pro vs Free Version](https://docs.uniwind.dev/pro-version)
31
- - [Migrate from Free Version](https://docs.uniwind.dev/pro/migrate-to-pro)
34
+ - [All Pro features](https://docs.uniwind.dev/pro/theme-transitions)
35
+ - [Migrate from Free Version](https://docs.uniwind.dev/migrate-to-pro)
32
36
 
33
37
  ## Features
34
38
 
package/package.json CHANGED
@@ -1,8 +1,19 @@
1
1
  {
2
2
  "name": "uniwind-pro",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.11",
4
4
  "type": "module",
5
5
  "description": "Uniwind Pro CLI",
6
+ "keywords": [
7
+ "tailwindcss",
8
+ "tailwind",
9
+ "react-native",
10
+ "styling",
11
+ "expo",
12
+ "css",
13
+ "unistyles",
14
+ "uniwind",
15
+ "pro"
16
+ ],
6
17
  "files": [
7
18
  "pre",
8
19
  "README.md",
@@ -16,14 +27,19 @@
16
27
  },
17
28
  "author": "Codemask",
18
29
  "license": "UNLICENSED",
19
- "devDependencies": {
20
- "@zowe/secrets-for-zowe-sdk": "8.27.4",
30
+ "dependencies": {
31
+ "@tailwindcss/node": "4.1.18",
32
+ "@tailwindcss/oxide": "4.1.18",
33
+ "@zowe/secrets-for-zowe-sdk": "8.29.4",
21
34
  "chalk": "5.6.2",
22
- "eventsource": "4.0.0",
23
- "figlet": "1.9.3",
24
- "inquirer": "12.10.0",
35
+ "chokidar": "5.0.0",
36
+ "culori": "4.0.2",
37
+ "eventsource": "4.1.0",
38
+ "figlet": "1.9.4",
39
+ "inquirer": "13.2.0",
25
40
  "jwt-decode": "4.0.0",
26
- "open": "10.2.0",
41
+ "lightningcss": "1.30.2",
42
+ "open": "11.0.0",
27
43
  "tar": "7.5.2"
28
44
  }
29
45
  }
@@ -17,7 +17,7 @@ export const login = async () => {
17
17
 
18
18
  open(authUrl)
19
19
 
20
- console.log(chalk.dim('\nWaiting for authorization response...'))
20
+ console.log(chalk.gray('\nWaiting for authorization response...'))
21
21
 
22
22
  const { token, handle } = await getTokenSSE(sessionId)
23
23
 
@@ -58,7 +58,7 @@ export const logout = async () => {
58
58
  const maybeCredentials = await keyring.findCredentials(SERVICE)
59
59
 
60
60
  if (maybeCredentials.length === 0) {
61
- console.log(chalk.yellow('No credentials found.'))
61
+ console.log(chalk.yellowBright('No credentials found.'))
62
62
 
63
63
  return Promise.resolve()
64
64
  }
@@ -67,5 +67,5 @@ export const logout = async () => {
67
67
  await keyring.deletePassword(SERVICE, account)
68
68
  }
69
69
 
70
- console.log(chalk.yellow('\nšŸ”‘ Signed out'))
70
+ console.log(chalk.yellowBright('\nšŸ”‘ Signed out'))
71
71
  }
package/pre/cli/index.js CHANGED
@@ -17,30 +17,32 @@ async function interactiveMode() {
17
17
  const session = await getSesionMetadata()
18
18
  const choices = session
19
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
- ]
20
+ new inquirer.Separator(
21
+ chalk.green(` Your session is valid for the next ${session.expiresAt}`)
22
+ ),
23
+ new inquirer.Separator(chalk.gray('────────────────────────────────────────────')),
24
+ { name: 'Manage your account', value: 'account' },
25
+ { name: 'Install Uniwind Pro', value: 'postinstall' },
26
+ { name: 'Logout', value: 'logout' },
27
+ { name: chalk.gray('Exit'), value: 'exit' },
28
+ ]
27
29
  : [
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
- ]
30
+ { name: 'Login with Github', value: 'login' },
31
+ { name: 'Buy Uniwind Pro', value: 'buy' },
32
+ { name: chalk.gray('Exit'), value: 'exit' },
33
+ ]
32
34
 
33
35
  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
+ ? `Hello @${session.handle}, what would you like to do?`
37
+ : 'What would you like to do?'
36
38
 
37
39
  const { action } = await inquirer.prompt([
38
40
  {
39
- type: 'list',
41
+ type: 'select',
40
42
  name: 'action',
41
43
  message,
42
- choices
43
- }
44
+ choices,
45
+ },
44
46
  ])
45
47
 
46
48
  switch (action) {
@@ -61,7 +63,7 @@ async function interactiveMode() {
61
63
  break
62
64
  case 'exit':
63
65
  shouldExit = true
64
- console.log(chalk.dim('\nSession closed\n'))
66
+ console.log(chalk.gray('\nSession closed\n'))
65
67
  break
66
68
  }
67
69
 
@@ -0,0 +1,67 @@
1
+ import { mkdirSync, writeFileSync, readdirSync, cpSync, rmSync, existsSync } from 'node:fs'
2
+ import { join } from 'node:path'
3
+ import { homedir } from 'node:os'
4
+
5
+ const CACHE_ROOT = join(homedir(), '.uniwind', 'cache', 'pro')
6
+
7
+ const getVersionCacheRoot = (packageVersion) => {
8
+ return join(CACHE_ROOT, packageVersion)
9
+ }
10
+
11
+ const getCacheDir = (packageVersion) => getVersionCacheRoot(packageVersion)
12
+
13
+ export const copyDirectoryContents = (fromDir, toDir) => {
14
+ for (const file of readdirSync(fromDir)) {
15
+ cpSync(join(fromDir, file), join(toDir, file), { recursive: true })
16
+ }
17
+ }
18
+
19
+ export const enforceCachePolicy = (packageVersion) => {
20
+ try {
21
+ mkdirSync(CACHE_ROOT, { recursive: true })
22
+
23
+ const gitIgnorePath = join(CACHE_ROOT, '.gitignore')
24
+
25
+ if (!existsSync(gitIgnorePath)) {
26
+ writeFileSync(gitIgnorePath, '*\n!.gitignore\n', 'utf8')
27
+ }
28
+ } catch {
29
+ return
30
+ }
31
+
32
+ try {
33
+ for (const entry of readdirSync(CACHE_ROOT, { withFileTypes: true })) {
34
+ if (entry.name !== packageVersion && entry.name !== '.gitignore') {
35
+ rmSync(join(CACHE_ROOT, entry.name), { recursive: true, force: true })
36
+ }
37
+ }
38
+ } catch {}
39
+ }
40
+
41
+ export const restoreFromCache = (packageVersion, targetDir) => {
42
+ const cacheDir = getCacheDir(packageVersion)
43
+
44
+ if (!existsSync(cacheDir)) {
45
+ return false
46
+ }
47
+
48
+ const cacheFiles = readdirSync(cacheDir)
49
+
50
+ if (cacheFiles.length === 0) {
51
+ return false
52
+ }
53
+
54
+ copyDirectoryContents(cacheDir, targetDir)
55
+
56
+ return true
57
+ }
58
+
59
+ export const saveToCache = (packageVersion, sourceDir) => {
60
+ try {
61
+ const cacheDir = getCacheDir(packageVersion)
62
+
63
+ rmSync(cacheDir, { recursive: true, force: true })
64
+ mkdirSync(cacheDir, { recursive: true })
65
+ copyDirectoryContents(sourceDir, cacheDir)
66
+ } catch {}
67
+ }
@@ -1,8 +1,45 @@
1
1
  import { Chalk } from 'chalk'
2
- import { keyring } from '@zowe/secrets-for-zowe-sdk'
2
+ import { mkdirSync, symlinkSync, existsSync } from 'node:fs'
3
+ import { dirname, join, resolve } from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
3
5
  import { UNIWIND_AUTH_TOKEN, SERVICE, UNIWIND_WEB_URL, HELP_EMAIL } from '../consts.js'
4
6
  import { downloadFromCI, downloadFromCLI } from './install.js'
5
7
 
8
+ // Create bin symlinks for aliased package
9
+ const createBinSymlinks = () => {
10
+ try {
11
+ const __dirname = dirname(fileURLToPath(import.meta.url))
12
+ const cliPath = resolve(__dirname, '../cli/index.js')
13
+ let current = __dirname
14
+
15
+ while (current !== '/') {
16
+ if (!current.includes('node_modules')) {
17
+ const binDir = join(current, 'node_modules', '.bin')
18
+ const nodeModules = join(current, 'node_modules')
19
+
20
+ if (existsSync(nodeModules)) {
21
+ // Now we're at the actual project root
22
+ mkdirSync(binDir, { recursive: true })
23
+
24
+ for (const name of ['uniwind', 'uniwind-pro']) {
25
+ const linkPath = join(binDir, name)
26
+
27
+ if (!existsSync(linkPath)) {
28
+ symlinkSync(cliPath, linkPath)
29
+ }
30
+ }
31
+
32
+ break
33
+ }
34
+ }
35
+
36
+ current = dirname(current)
37
+ }
38
+ } catch {}
39
+ }
40
+
41
+ createBinSymlinks()
42
+
6
43
  const chalk = new Chalk({ level: 3 })
7
44
 
8
45
  const main = async () => {
@@ -12,6 +49,7 @@ const main = async () => {
12
49
  return await downloadFromCI(maybeCICDToken)
13
50
  }
14
51
 
52
+ const { keyring } = await import('@zowe/secrets-for-zowe-sdk')
15
53
  const matchingCredentials = await keyring.findCredentials(SERVICE)
16
54
 
17
55
  if (matchingCredentials.length !== 0) {
@@ -24,7 +62,7 @@ const main = async () => {
24
62
  main().catch((error) => {
25
63
  console.log(chalk.red.bold("Access denied: You don't have permission to install this package.\n"))
26
64
  console.log(
27
- chalk.dim.red(
65
+ chalk.red(
28
66
  `To get a license, visit ${chalk.bold.underline(UNIWIND_WEB_URL)}.\n` +
29
67
  `If you already have one, run cli via:\n\n` +
30
68
  `${chalk.bold('uniwind-pro')}\n\n` +
@@ -33,7 +71,7 @@ main().catch((error) => {
33
71
  )
34
72
  )
35
73
 
36
- console.log(chalk.dim.gray(error.message))
74
+ console.log(chalk.gray(error.message))
37
75
 
38
76
  process.exit(1)
39
77
  })
@@ -1,16 +1,21 @@
1
1
  import chalk from 'chalk'
2
- import { readFileSync, mkdirSync, readdirSync, cpSync, rmSync } from 'node:fs'
3
- import { keyring } from '@zowe/secrets-for-zowe-sdk'
2
+ import { readFileSync, mkdirSync, readdirSync, rmSync, existsSync } from 'node:fs'
4
3
  import { join, dirname } from 'node:path'
5
4
  import { fileURLToPath } from 'node:url'
6
5
  import { pipeline } from 'node:stream'
7
6
  import { promisify } from 'node:util'
8
7
  import { x as extract } from 'tar'
9
8
  import { INSTALLATION_URL, SERVICE } from '../consts.js'
9
+ import {
10
+ copyDirectoryContents,
11
+ enforceCachePolicy,
12
+ restoreFromCache,
13
+ saveToCache,
14
+ } from './cache.js'
10
15
 
11
16
  const __dirname = dirname(fileURLToPath(import.meta.url))
12
- const pkgPath = join(__dirname, '../../package.json')
13
- const rootPkgPath = join(__dirname, '../../../../package.json')
17
+ const PKG_ROOT = join(__dirname, '../../')
18
+ const pkgPath = join(PKG_ROOT, 'package.json')
14
19
  const streamPipeline = promisify(pipeline)
15
20
 
16
21
  const getVersion = () => {
@@ -25,21 +30,89 @@ const getVersion = () => {
25
30
  }
26
31
  }
27
32
 
28
- const getProjectName = () => {
29
- try {
30
- const packageJson = readFileSync(rootPkgPath, 'utf8')
31
- const parsedPackageJSON = JSON.parse(packageJson)
33
+ const findWorkspacePackages = (rootDir, workspaces) => {
34
+ const packages = []
32
35
 
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
- )
36
+ for (const pattern of workspaces) {
37
+ const wsPath = join(rootDir, pattern.replace('/*', ''))
38
+
39
+ if (existsSync(wsPath)) {
40
+ try {
41
+ const dirs = readdirSync(wsPath, { withFileTypes: true })
42
+
43
+ for (const dir of dirs) {
44
+ if (dir.isDirectory()) {
45
+ const pkgPath = join(wsPath, dir.name, 'package.json')
46
+
47
+ if (existsSync(pkgPath)) {
48
+ packages.push(pkgPath)
49
+ }
50
+ }
51
+ }
52
+ } catch {}
53
+ }
38
54
  }
55
+
56
+ return packages
57
+ }
58
+
59
+ const getProjectName = () => {
60
+ let current = __dirname
61
+
62
+ while (current !== '/') {
63
+ if (!current.includes('node_modules')) {
64
+ const pkgPath = join(current, 'package.json')
65
+
66
+ if (existsSync(pkgPath)) {
67
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'))
68
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies }
69
+
70
+ // Direct dependency - return immediately
71
+ if (deps['uniwind'] || deps['uniwind-pro']) {
72
+ return pkg.name
73
+ }
74
+
75
+ // Monorepo with workspaces - search for package that depends on uniwind
76
+ if (pkg.workspaces) {
77
+ const workspaces = Array.isArray(pkg.workspaces)
78
+ ? pkg.workspaces
79
+ : pkg.workspaces.packages || []
80
+ const wsPkgs = findWorkspacePackages(current, workspaces)
81
+
82
+ for (const wsPkgPath of wsPkgs) {
83
+ try {
84
+ const wsPkg = JSON.parse(readFileSync(wsPkgPath, 'utf8'))
85
+ const wsDeps = { ...wsPkg.dependencies, ...wsPkg.devDependencies }
86
+
87
+ if (wsDeps['uniwind'] || wsDeps['uniwind-pro']) {
88
+ return wsPkg.name
89
+ }
90
+ } catch {}
91
+ }
92
+ }
93
+
94
+ // Fallback to root package name
95
+ return pkg.name
96
+ }
97
+ }
98
+
99
+ current = dirname(current)
100
+ }
101
+
102
+ throw new Error('Could not find project package.json')
39
103
  }
40
104
 
41
105
  export const downloadFromCI = async (licenseUUID) => {
42
106
  const packageVersion = getVersion()
107
+
108
+ enforceCachePolicy(packageVersion)
109
+
110
+ if (restoreFromCache(packageVersion, PKG_ROOT)) {
111
+ console.log(chalk.gray(`Using cached v${packageVersion} package...\n`))
112
+
113
+ return
114
+ }
115
+
43
116
  const cdnUrl = `${INSTALLATION_URL}/ci/${packageVersion}/${licenseUUID}`
44
117
  const response = await fetch(cdnUrl)
45
118
 
@@ -47,23 +120,32 @@ export const downloadFromCI = async (licenseUUID) => {
47
120
  throw new Error(`Download failed: ${response.status} ${response.statusText}`)
48
121
  }
49
122
 
50
- return await install(response.body)
123
+ return await install(response.body, packageVersion)
51
124
  }
52
125
 
53
126
  export const downloadFromCLI = async ({ account: handle, password: token }) => {
54
127
  const packageVersion = getVersion()
55
128
  const projectName = getProjectName()
56
129
 
57
- console.log(chalk.dim(`Fetching v${packageVersion} for project "${projectName}"...\n`))
130
+ enforceCachePolicy(packageVersion)
131
+
132
+ if (restoreFromCache(packageVersion, PKG_ROOT)) {
133
+ console.log(chalk.gray(`Using cached v${packageVersion} for project "${projectName}".\n`))
134
+
135
+ return
136
+ }
137
+
138
+ console.log(chalk.gray(`Fetching v${packageVersion} for project "${projectName}"...\n`))
58
139
 
59
- const cdnUrl = `${INSTALLATION_URL}/cli/${handle}/${projectName}/${packageVersion}/${token}`
140
+ const cdnUrl = `${INSTALLATION_URL}/cli/${handle}/${encodeURIComponent(projectName)}/${packageVersion}/${token}`
60
141
  const response = await fetch(cdnUrl)
61
142
 
62
143
  if (response.ok) {
63
- return await install(response.body)
144
+ return await install(response.body, packageVersion)
64
145
  }
65
146
 
66
147
  if (response.status === 401) {
148
+ const { keyring } = await import('@zowe/secrets-for-zowe-sdk')
67
149
  await keyring.deleteCredentials(SERVICE)
68
150
  }
69
151
 
@@ -76,8 +158,8 @@ export const downloadFromCLI = async ({ account: handle, password: token }) => {
76
158
  }
77
159
  }
78
160
 
79
- const install = async (stream) => {
80
- const TMP_DIR = join(__dirname, '../../_package')
161
+ const install = async (stream, packageVersion) => {
162
+ const TMP_DIR = join(PKG_ROOT, '_package')
81
163
 
82
164
  mkdirSync(TMP_DIR, { recursive: true })
83
165
 
@@ -89,9 +171,8 @@ const install = async (stream) => {
89
171
  })
90
172
  )
91
173
 
92
- for (const file of readdirSync(TMP_DIR)) {
93
- cpSync(join(TMP_DIR, file), join(__dirname, '../../', file), { recursive: true })
94
- }
174
+ copyDirectoryContents(TMP_DIR, PKG_ROOT)
175
+ saveToCache(packageVersion, TMP_DIR)
95
176
 
96
177
  rmSync(TMP_DIR, { recursive: true, force: true })
97
178
  }