@yahoo/uds 2.0.0-beta.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cli/README.md +50 -0
- package/cli/bin/uds-darwin-arm64-baseline +0 -0
- package/cli/bin/uds-linux-arm64 +0 -0
- package/cli/bin/uds-linux-x64-baseline +0 -0
- package/cli/cli.ts +21 -4
- package/cli/commands/codemod/codemod.ts +12 -9
- package/cli/commands/codemod/sizingProps.ts +1 -1
- package/cli/commands/login.ts +30 -0
- package/cli/commands/logout.ts +27 -0
- package/cli/commands/purge.ts +3 -1
- package/cli/commands/sync.ts +2 -0
- package/cli/commands/uds.ts +6 -1
- package/cli/commands/version.ts +2 -0
- package/cli/compile.ts +8 -9
- package/cli/consts.ts +5 -2
- package/cli/env.d.ts +5 -0
- package/cli/exec.ts +1 -1
- package/cli/preload.ts +17 -0
- package/cli/tsconfig.json +4 -4
- package/cli/uds-cli +6 -2
- package/cli/utils/analytics.ts +26 -0
- package/cli/utils/auth.ts +338 -0
- package/cli/utils/client_secrets.json +23 -0
- package/cli/utils/client_secrets.json.enc +0 -0
- package/cli/utils/configWorker.ts +3 -2
- package/cli/utils/secrets.ts +40 -0
- package/dist/analytics/server.cjs +1 -0
- package/dist/analytics/server.d.cts +1 -0
- package/dist/analytics/server.d.ts +1 -0
- package/dist/analytics/server.js +1 -0
- package/dist/chunk-3PK6DOFO.js +3 -0
- package/dist/chunk-5WBROFT5.cjs +1 -0
- package/dist/chunk-DCXVARRB.cjs +1 -0
- package/dist/chunk-DMMTEAJW.cjs +2 -0
- package/dist/chunk-EYFQOFYW.cjs +1 -0
- package/dist/chunk-FWF2C6TL.cjs +1 -0
- package/dist/chunk-GIJ2FHY5.cjs +1 -0
- package/dist/chunk-IUL5ZI4O.js +2 -0
- package/dist/chunk-JGIKFUBH.cjs +2 -0
- package/dist/chunk-P5B5IOMM.js +2 -0
- package/dist/chunk-PE2P7J44.js +2 -0
- package/dist/chunk-PFT3UA6K.cjs +2 -0
- package/dist/chunk-SUASN3GG.js +2 -0
- package/dist/chunk-VPR62GYQ.js +2 -0
- package/dist/chunk-X6F5UEQ5.js +2 -0
- package/dist/chunk-YM5TKITI.js +2 -0
- package/dist/chunk-YUHY3FXT.cjs +1 -0
- package/dist/chunk-ZV62SW5G.js +1 -0
- package/dist/client/index.cjs +3 -0
- package/dist/client/index.d.cts +97 -0
- package/dist/client/index.d.ts +97 -0
- package/dist/client/index.js +4 -0
- package/dist/experimental/index.cjs +2 -0
- package/dist/experimental/index.d.cts +469 -0
- package/dist/experimental/index.d.ts +469 -0
- package/dist/experimental/index.js +2 -0
- package/dist/fixtures.cjs +1506 -0
- package/dist/fixtures.d.cts +94 -0
- package/dist/fixtures.d.ts +94 -0
- package/dist/fixtures.js +1449 -0
- package/dist/flags.cjs +1 -0
- package/dist/flags.d.cts +17 -0
- package/dist/flags.d.ts +17 -0
- package/dist/flags.js +2 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +385 -0
- package/dist/index.d.ts +385 -0
- package/dist/index.js +1 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/motionFeatures-I76FFCTS.js +1 -0
- package/dist/motionFeatures-P3FQL2KP.cjs +1 -0
- package/dist/styles/toast.css +3 -0
- package/dist/styles/toast.d.cts +2 -0
- package/dist/styles/toast.d.ts +2 -0
- package/dist/tailwind/plugin.cjs +2 -0
- package/dist/tailwind/plugin.d.cts +60 -0
- package/dist/tailwind/plugin.d.ts +60 -0
- package/dist/tailwind/plugin.js +2 -0
- package/dist/tailwind/purger.cjs +5 -0
- package/dist/tailwind/purger.d.cts +17 -0
- package/dist/tailwind/purger.d.ts +17 -0
- package/dist/tailwind/purger.js +6 -0
- package/dist/tailwind/tsMorph.cjs +1 -0
- package/dist/tailwind/tsMorph.d.cts +31 -0
- package/dist/tailwind/tsMorph.d.ts +31 -0
- package/dist/tailwind/tsMorph.js +1 -0
- package/dist/tailwind/utils.cjs +1 -0
- package/dist/tailwind/utils.d.cts +99 -0
- package/dist/tailwind/utils.d.ts +99 -0
- package/dist/tailwind/utils.js +1 -0
- package/dist/tokens/index.cjs +1 -0
- package/dist/tokens/index.d.cts +1127 -0
- package/dist/tokens/index.d.ts +1127 -0
- package/dist/tokens/index.js +1 -0
- package/dist/tokens/parseTokens.cjs +1 -0
- package/dist/tokens/parseTokens.d.cts +59 -0
- package/dist/tokens/parseTokens.d.ts +59 -0
- package/dist/tokens/parseTokens.js +1 -0
- package/dist/types-Pyccco5Q.d.cts +949 -0
- package/dist/types-Pyccco5Q.d.ts +949 -0
- package/fonts/mobile.cjs +1 -1
- package/package.json +183 -156
- package/cli/codemods/propsToClass.test.tsx +0 -97
- package/cli/utils/purgeCSS.test.ts +0 -210
package/cli/README.md
CHANGED
@@ -3,6 +3,11 @@ import { Box, VStack } from '@yahoo/uds';
|
|
3
3
|
import { RequiredChip } from '~/components/RequiredChip';
|
4
4
|
import { DocImage } from '~/components/DocImage';
|
5
5
|
import { PACKAGE_MANAGERS, CommandSnippet } from '~/components/CommandSnippet';
|
6
|
+
import { toPageTitle } from '~/utils/toPageTitle';
|
7
|
+
|
8
|
+
export const metadata = {
|
9
|
+
title: toPageTitle({ title: 'CLI', category: 'Tools' }),
|
10
|
+
};
|
6
11
|
|
7
12
|
# Universal CLI
|
8
13
|
|
@@ -18,6 +23,17 @@ The Universal CLI is available as command, `uds`. The tool was created with [Blu
|
|
18
23
|
|
19
24
|
1. To use the CLI, first [install](/docs/getting-started/quick-start#installation) the `@yahoo/uds` package as a dependency in your package.json, which has the UDS CLI as a binary.
|
20
25
|
|
26
|
+
2. Log in to the CLI
|
27
|
+
|
28
|
+
<VStack spacingBottom="2">
|
29
|
+
<DocTabs
|
30
|
+
items={PACKAGE_MANAGERS.map((packageManager) => ({
|
31
|
+
label: packageManager,
|
32
|
+
content: <CommandSnippet name={packageManager} command="bun uds login" />,
|
33
|
+
}))}
|
34
|
+
/>
|
35
|
+
</VStack>
|
36
|
+
|
21
37
|
## Commands
|
22
38
|
|
23
39
|
> **Note**: If you are _not_ running the CLI from a package.json script you will need to call your package manager execute command before the binary in order to run it directly. i.e. `npx uds purge`
|
@@ -128,6 +144,24 @@ Any file added to commands/codemod will be available in prompt land.
|
|
128
144
|
uds codemod
|
129
145
|
```
|
130
146
|
|
147
|
+
### Login
|
148
|
+
|
149
|
+
The `uds login` command is used to authenticate the user to the CLI. We use
|
150
|
+
Google's OAuth2 flow, which is the same login flow used by the [Configurator](/docs/getting-started/using-configurator) and the documentation site. Logging in to the CLI helps us identify and track CLI usage and metrics.
|
151
|
+
|
152
|
+
### Circumventing Login
|
153
|
+
|
154
|
+
There may be situations (such as CI runs) where you can't authenticate your personal account with the CLI. For this case, providing the `CI=true` and `UDS_TEAM_SLUG` env variables is required when using the CLI in a CI environment:
|
155
|
+
|
156
|
+
```env
|
157
|
+
CI=true
|
158
|
+
UDS_TEAM_SLUG=<your-team-slug> uds <command>
|
159
|
+
```
|
160
|
+
|
161
|
+
Your team slug can be found in your team's Configurator URL path:
|
162
|
+
|
163
|
+
<DocImage light={{ src: '/images/team-slug-screenshot.png' }} />
|
164
|
+
|
131
165
|
### Expo (WIP)
|
132
166
|
|
133
167
|
The `uds expo` command is for building and launching React Native apps using Expo.
|
@@ -153,6 +187,22 @@ Commands are organized in a tree structure in `uds/cli/commands`. The root comma
|
|
153
187
|
|
154
188
|
Adding nested commands, i.e. `uds expo dev` does work correctly when UDS is consumed from npm. As a workaround, please see code for expo/expo.ts for re-routing sub-commands from the root command file. To verify your CLI command works correctly you should run `npm pack` within the packages/uds directory. Once you have your generated tarball you should copy that tarball to a test application such as https://github.com/yahoo-uds/uds-nextjs-demo, then add `"@yahoo/uds": "file:./tarball-generated-from-npm-pack.tgz` to it's dependencies and run an install. Now you should be able to run `bun uds [your command name]` to test your functionality.
|
155
189
|
|
190
|
+
### Testing the login flow
|
191
|
+
|
192
|
+
To test the login flow, the CLI starts a web server and opens browser window to
|
193
|
+
a login page in Configurator. In prod, it opens https://config.uds.build/login.
|
194
|
+
In local dev, http://localhost:4001/login is opened.
|
195
|
+
|
196
|
+
In the root of the UDS monorepo, run the following commands:
|
197
|
+
|
198
|
+
```
|
199
|
+
# Start configurator app web server:
|
200
|
+
turbo --filter uds-configurator dev
|
201
|
+
|
202
|
+
# Run the CLI login command:
|
203
|
+
bun run --cwd packages/uds uds login
|
204
|
+
```
|
205
|
+
|
156
206
|
### API Reference
|
157
207
|
|
158
208
|
Bluebun comes with a number of built-in utilities that are exported from the main `bluebun` package. See [reference guide](https://github.com/jamonholmgren/bluebun/blob/main/docs/reference.md) for more.
|
Binary file
|
Binary file
|
Binary file
|
package/cli/cli.ts
CHANGED
@@ -2,12 +2,14 @@
|
|
2
2
|
// Start bluebun to run the correct CLI command
|
3
3
|
import { parseArgs } from 'node:util';
|
4
4
|
|
5
|
-
import { run } from 'bluebun';
|
5
|
+
import { print, red, run } from 'bluebun';
|
6
6
|
|
7
|
-
|
7
|
+
import { getAuthenticatedUser } from './utils/auth';
|
8
|
+
|
9
|
+
async function main() {
|
8
10
|
// We need to pass the path from Node to the Bun binaries
|
9
11
|
// because there's an issue where the Bun binaries struggle to resolve
|
10
|
-
const { values } = parseArgs({
|
12
|
+
const { values, positionals } = parseArgs({
|
11
13
|
args: Bun.argv,
|
12
14
|
options: {
|
13
15
|
commandsPath: {
|
@@ -18,9 +20,24 @@ function main() {
|
|
18
20
|
allowPositionals: true,
|
19
21
|
});
|
20
22
|
|
23
|
+
const cliPath = values.commandsPath!.toString();
|
24
|
+
const isLoginCmd = positionals.includes('login');
|
25
|
+
|
26
|
+
if (!isLoginCmd) {
|
27
|
+
const user = await getAuthenticatedUser(cliPath);
|
28
|
+
if (!user) {
|
29
|
+
print(
|
30
|
+
red(
|
31
|
+
'🚨 Sign-in required. Please run `uds login` and use a @yahooinc.com email during sign-in.',
|
32
|
+
),
|
33
|
+
);
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
21
38
|
run({
|
22
39
|
name: 'uds',
|
23
|
-
cliPath
|
40
|
+
cliPath,
|
24
41
|
});
|
25
42
|
}
|
26
43
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { type Props } from 'bluebun';
|
2
2
|
import prompts from 'prompts';
|
3
3
|
|
4
|
+
import { trackEvent } from '../../utils/analytics';
|
4
5
|
import { getCommandHelp, getSubCommandsChoices } from '../../utils/getCommandHelp';
|
5
6
|
import { getDirChoices } from '../../utils/getDirChoices';
|
6
7
|
|
@@ -13,6 +14,11 @@ export default {
|
|
13
14
|
const isRootCommand = Boolean(!props?.first);
|
14
15
|
const dirChoices = getDirChoices();
|
15
16
|
|
17
|
+
const runCodeMod = async (codemod: string, selectedDirs: string[]) => {
|
18
|
+
const mod = (await import(`./${codemod}`)).default;
|
19
|
+
return mod.run({ ...props, selectedDirs });
|
20
|
+
};
|
21
|
+
|
16
22
|
if (isRootCommand) {
|
17
23
|
// Prompt the user to setup the codemod runner
|
18
24
|
const { selectedDirs, selectedCodemods, didConfirm } = await prompts([
|
@@ -49,10 +55,9 @@ export default {
|
|
49
55
|
|
50
56
|
// Run each codemod and provide the selectedDirs
|
51
57
|
return Promise.all(
|
52
|
-
selectedCodemods.map(async (
|
53
|
-
|
54
|
-
|
55
|
-
);
|
58
|
+
selectedCodemods.map(async (codemod: string) => {
|
59
|
+
await runCodeMod(codemod, selectedDirs);
|
60
|
+
return trackEvent('codemod', { codemod });
|
56
61
|
}),
|
57
62
|
);
|
58
63
|
} else if (subCommandIsValid) {
|
@@ -71,11 +76,9 @@ export default {
|
|
71
76
|
process.exit(1);
|
72
77
|
}
|
73
78
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
selectedDirs,
|
78
|
-
});
|
79
|
+
const codemod = props.first!;
|
80
|
+
await runCodeMod(codemod, selectedDirs);
|
81
|
+
return trackEvent('codemod', { codemod });
|
79
82
|
} else {
|
80
83
|
// Throw the help message
|
81
84
|
await getCommandHelp({
|
@@ -6,7 +6,7 @@ import { sizingPropToClassMap } from '../../codemods/utils/sizingPropToClassMap'
|
|
6
6
|
export default {
|
7
7
|
name: 'sizingProps',
|
8
8
|
description: `Convert sizing props to classNames`,
|
9
|
-
|
9
|
+
|
10
10
|
run: async (props: Props & { selectedDirs?: string[] }) => {
|
11
11
|
spinStart('Running codemod...');
|
12
12
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { magenta, print, red } from 'bluebun';
|
2
|
+
|
3
|
+
import { trackEvent } from '../utils/analytics';
|
4
|
+
import { login } from '../utils/auth';
|
5
|
+
|
6
|
+
export default {
|
7
|
+
name: 'login',
|
8
|
+
description: '👤 Log in to UDS CLI',
|
9
|
+
alias: ['auth'],
|
10
|
+
run: async () => {
|
11
|
+
try {
|
12
|
+
const user = await login();
|
13
|
+
if (user) {
|
14
|
+
print(magenta(`🔒 Logged in as ${user.email}`));
|
15
|
+
return await trackEvent('login');
|
16
|
+
}
|
17
|
+
} catch (error) {
|
18
|
+
if (error instanceof Error) {
|
19
|
+
print(red(error.message));
|
20
|
+
} else {
|
21
|
+
print(
|
22
|
+
red(
|
23
|
+
`❌ An error occurred while logging in. Please ask in the #uds-ask channel for support.`,
|
24
|
+
),
|
25
|
+
);
|
26
|
+
process.exitCode = 1;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
},
|
30
|
+
};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { magenta, print, red } from 'bluebun';
|
2
|
+
|
3
|
+
import { trackEvent } from '../utils/analytics';
|
4
|
+
import { logout } from '../utils/auth';
|
5
|
+
|
6
|
+
export default {
|
7
|
+
name: 'logout',
|
8
|
+
description: '👤 Sign out of UDS CLI',
|
9
|
+
run: async () => {
|
10
|
+
try {
|
11
|
+
// Track logout event before logout is run. Otherwise, there's no user object to track.
|
12
|
+
await trackEvent('logout');
|
13
|
+
await logout();
|
14
|
+
print(magenta('👋 You have been logged out.'));
|
15
|
+
} catch (error) {
|
16
|
+
if (error instanceof Error) {
|
17
|
+
print(red(error.message));
|
18
|
+
} else {
|
19
|
+
print(
|
20
|
+
red(
|
21
|
+
`❌ An error occurred while logging out. Please ask in the #uds-ask channel for support.`,
|
22
|
+
),
|
23
|
+
);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
},
|
27
|
+
};
|
package/cli/commands/purge.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Props, spinStart, spinStop } from 'bluebun';
|
2
2
|
|
3
|
+
import { trackEvent } from '../utils/analytics';
|
3
4
|
import { purge, PurgeOptions } from '../utils/purgeCSS';
|
4
5
|
|
5
6
|
interface PurgeProps extends Props {
|
@@ -9,12 +10,13 @@ interface PurgeProps extends Props {
|
|
9
10
|
export default {
|
10
11
|
name: 'purge',
|
11
12
|
description: `Purge unused CSS`,
|
12
|
-
|
13
|
+
|
13
14
|
run: async (props: PurgeProps) => {
|
14
15
|
spinStart('Purging css started...');
|
15
16
|
try {
|
16
17
|
await purge(props.options);
|
17
18
|
spinStop('✅', 'Purging css done!');
|
19
|
+
return await trackEvent('purge');
|
18
20
|
} catch (error) {
|
19
21
|
if (error instanceof Error) {
|
20
22
|
spinStop('❌', error.message);
|
package/cli/commands/sync.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { magenta, print, Props } from 'bluebun';
|
2
2
|
|
3
|
+
import { trackEvent } from '../utils/analytics';
|
3
4
|
import { setupConfigWorker } from '../utils/setupConfigWorker';
|
4
5
|
import { SyncOptions } from '../utils/types';
|
5
6
|
|
@@ -31,6 +32,7 @@ export default {
|
|
31
32
|
}
|
32
33
|
},
|
33
34
|
});
|
35
|
+
return await trackEvent('sync', { id });
|
34
36
|
} catch {
|
35
37
|
console.error(
|
36
38
|
'❌ An error occurred while syncing. Please reach out to #uds-ask channel for support.',
|
package/cli/commands/uds.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { print, type Props, red } from 'bluebun';
|
2
2
|
|
3
|
+
import { trackEvent } from '../utils/analytics';
|
4
|
+
import { getAuthenticatedUser } from '../utils/auth';
|
3
5
|
import { getCommandHelp } from '../utils/getCommandHelp';
|
4
6
|
|
5
7
|
export default {
|
@@ -8,7 +10,10 @@ export default {
|
|
8
10
|
run: async (props: Props) => {
|
9
11
|
if (props.first) {
|
10
12
|
print(red(`Unknown command: ${props.first}`));
|
13
|
+
await trackEvent('unknown_cmd', { cmd: props.first });
|
11
14
|
}
|
12
|
-
await
|
15
|
+
const user = await getAuthenticatedUser();
|
16
|
+
const notes = user ? `🔒 Logged in as ${user.email}` : undefined;
|
17
|
+
await getCommandHelp({ ...props, notes });
|
13
18
|
},
|
14
19
|
};
|
package/cli/commands/version.ts
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
import { print } from 'bluebun';
|
2
2
|
|
3
3
|
import packageJson from '../../package.json';
|
4
|
+
import { trackEvent } from '../utils/analytics';
|
4
5
|
|
5
6
|
export default {
|
6
7
|
name: 'version',
|
7
8
|
description: `${packageJson.version}`,
|
8
9
|
run: async () => {
|
9
10
|
print(packageJson.version);
|
11
|
+
await trackEvent('version', { version: packageJson.version });
|
10
12
|
},
|
11
13
|
};
|
package/cli/compile.ts
CHANGED
@@ -11,25 +11,24 @@ const __dirname = path.dirname(__filename);
|
|
11
11
|
const libPath = __dirname;
|
12
12
|
const entry = path.join(libPath, './cli.ts');
|
13
13
|
|
14
|
-
|
14
|
+
async function main() {
|
15
15
|
// Compile the UDS CLI for all the supported platforms
|
16
16
|
await Promise.all(
|
17
|
-
SUPPORTED_BUN_PLATFORMS.map(
|
18
|
-
console.log(`Building UDS CLI for ${
|
19
|
-
|
17
|
+
SUPPORTED_BUN_PLATFORMS.map((platform) => {
|
18
|
+
console.log(`Building UDS CLI for ${platform}`);
|
19
|
+
return $`bun build --compile --minify --sourcemap --target=bun-${platform} ${entry} --outfile ${path.join(libPath, './bin', `./uds-${platform}`)}`.quiet();
|
20
20
|
}),
|
21
21
|
);
|
22
22
|
|
23
23
|
// Compile the script that will auto-detect the platform and architecture
|
24
|
-
const shellOutput = await $`bun build ${path.join(libPath, './exec.ts')} --target node
|
24
|
+
const shellOutput = await $`bun build ${path.join(libPath, './exec.ts')} --target node`.text();
|
25
25
|
|
26
26
|
// Add shebang at the top of the file and write to disk
|
27
27
|
await Bun.write(
|
28
28
|
path.join(libPath, './uds-cli'),
|
29
29
|
`#!/usr/bin/env node \n
|
30
|
-
// Note: This file is generated, do not edit directly! Edit exec.ts instead. \n` +
|
31
|
-
shellOutput.text(),
|
30
|
+
// Note: This file is generated, do not edit directly! Edit exec.ts instead. \n` + shellOutput,
|
32
31
|
);
|
33
|
-
}
|
32
|
+
}
|
34
33
|
|
35
|
-
|
34
|
+
main();
|
package/cli/consts.ts
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
// Supported target platforms by Bun
|
2
2
|
// https://bun.sh/docs/bundler/executables#cross-compile-to-other-platforms
|
3
|
-
export const SUPPORTED_BUN_PLATFORMS = [
|
4
|
-
|
3
|
+
export const SUPPORTED_BUN_PLATFORMS = [
|
4
|
+
'linux-x64-baseline',
|
5
|
+
'linux-arm64',
|
6
|
+
'darwin-arm64-baseline',
|
7
|
+
];
|
package/cli/env.d.ts
CHANGED
@@ -14,6 +14,11 @@ declare module 'bun' {
|
|
14
14
|
EXPO_USE_METRO_WORKSPACE_ROOT?: string;
|
15
15
|
EXPO_BUNDLE_APP?: string;
|
16
16
|
ESLINT_USE_FLAT_CONFIG?: string;
|
17
|
+
/** UDS purge command - which color and scale modes to keep */
|
17
18
|
ENABLED_SCALE_AND_COLOR_MODES?: string;
|
19
|
+
/** UDS config id */
|
20
|
+
UDS_ID?: string;
|
21
|
+
/** UDS sync command - filename to write the config output */
|
22
|
+
UDS_OUT_FILE?: string;
|
18
23
|
}
|
19
24
|
}
|
package/cli/exec.ts
CHANGED
package/cli/preload.ts
CHANGED
@@ -44,3 +44,20 @@ mock.module('@yahoo/uds/tailwind/purger', () => ({
|
|
44
44
|
Button: '',
|
45
45
|
},
|
46
46
|
}));
|
47
|
+
|
48
|
+
mock.module('googleapis', () => ({
|
49
|
+
google: {
|
50
|
+
auth: {
|
51
|
+
OAuth2: mock(() => {}).mockImplementation(() => ({
|
52
|
+
getToken: () => Promise.resolve({ tokens: 'test' }),
|
53
|
+
setCredentials: mock(() => {}),
|
54
|
+
generateAuthUrl: mock(() => 'https://accounts.google.com/o/oauth2/v2/auth'),
|
55
|
+
})),
|
56
|
+
},
|
57
|
+
oauth2: () => ({
|
58
|
+
userinfo: {
|
59
|
+
get: () => Promise.resolve({ data: { email: 'foo@yahooinc.com' } }),
|
60
|
+
},
|
61
|
+
}),
|
62
|
+
},
|
63
|
+
}));
|
package/cli/tsconfig.json
CHANGED
@@ -18,14 +18,14 @@
|
|
18
18
|
"strict": true,
|
19
19
|
"types": ["bun-types"],
|
20
20
|
"target": "esnext",
|
21
|
-
"lib": ["
|
21
|
+
"lib": ["ESNext"],
|
22
22
|
"module": "esnext",
|
23
23
|
"moduleResolution": "bundler",
|
24
24
|
"paths": {
|
25
25
|
"@yahoo/uds/scripts/*": ["../scripts/*"],
|
26
26
|
"@yahoo/uds/*": ["../src/*"],
|
27
27
|
"@yahoo/uds/tailwind/tsMorph": ["../scripts/utils/tsMorph.ts"],
|
28
|
-
"root/*": ["../../*"]
|
29
|
-
}
|
30
|
-
}
|
28
|
+
"root/*": ["../../*"]
|
29
|
+
}
|
30
|
+
}
|
31
31
|
}
|
package/cli/uds-cli
CHANGED
@@ -7,7 +7,11 @@ import path from "path";
|
|
7
7
|
import { fileURLToPath } from "url";
|
8
8
|
|
9
9
|
// cli/consts.ts
|
10
|
-
var SUPPORTED_BUN_PLATFORMS = [
|
10
|
+
var SUPPORTED_BUN_PLATFORMS = [
|
11
|
+
"linux-x64-baseline",
|
12
|
+
"linux-arm64",
|
13
|
+
"darwin-arm64-baseline"
|
14
|
+
];
|
11
15
|
|
12
16
|
// cli/exec.ts
|
13
17
|
var detectPlatform = () => {
|
@@ -23,7 +27,7 @@ var detectPlatform = () => {
|
|
23
27
|
stdio: "inherit"
|
24
28
|
});
|
25
29
|
} else {
|
26
|
-
throw new Error("Unsupported platform \uD83D\uDE22,
|
30
|
+
throw new Error("Unsupported platform \uD83D\uDE22, please reach out to the UDS team for support #uds-ask.");
|
27
31
|
}
|
28
32
|
};
|
29
33
|
detectPlatform();
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import {
|
2
|
+
type EventName,
|
3
|
+
GA_MEASUREMENT_IDS,
|
4
|
+
GA_MEASUREMENT_SECRETS,
|
5
|
+
track,
|
6
|
+
} from '@yahoo/uds/analytics/server';
|
7
|
+
|
8
|
+
import { getAuthenticatedUser } from './auth';
|
9
|
+
|
10
|
+
export async function setup() {
|
11
|
+
const user = await getAuthenticatedUser();
|
12
|
+
if (user) {
|
13
|
+
await track.init({
|
14
|
+
appName: 'cli',
|
15
|
+
apiSecret: GA_MEASUREMENT_SECRETS.cli,
|
16
|
+
measurementId: GA_MEASUREMENT_IDS.cli,
|
17
|
+
// @ts-expect-error type is fine
|
18
|
+
user,
|
19
|
+
});
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
export async function trackEvent(...args: Parameters<typeof track.event<EventName['cli']>>) {
|
24
|
+
await setup();
|
25
|
+
await track.event(...args);
|
26
|
+
}
|