@servicetitan/docs-uikit 32.4.0 → 32.5.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/docs/install.mdx +171 -0
- package/docs/startup/install.mdx +8 -0
- package/docs/startup/review.mdx +24 -3
- package/package.json +2 -2
package/docs/install.mdx
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Installing Dependencies
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import Tabs from '@theme/Tabs';
|
|
6
|
+
import TabItem from '@theme/TabItem';
|
|
7
|
+
|
|
8
|
+
#### [CHANGELOG (@servicetitan/install)](https://github.com/servicetitan/uikit/blob/master/packages/install/CHANGELOG.md)
|
|
9
|
+
|
|
10
|
+
`@servicetitan/install` is a lightweight wrapper around `npm install` that automatically configures access to private ServiceTitan packages and runs `npm install` with ServiceTitan's standard options. Use it instead of plain `npm install` to guarantee that all packages are installed correctly and any necessary pre- and post-installation steps are performed.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npx --yes @servicetitan/install
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
See [package.json in the example project](https://github.com/search?q=repo%3Aservicetitan%2Ffrontend-example+path%3A**%2Fpackage.json+%5C%22bootstrap%5C%22&type=code) for how to use `install` in an npm script.
|
|
17
|
+
|
|
18
|
+
:::info
|
|
19
|
+
Previously, we recommended using `npx --yes @servicetitan/startup install` to bootstrap projects.
|
|
20
|
+
But as `@servicetitan/startup` grew more features, it became too large for simple bootstrapping.
|
|
21
|
+
The dedicated `@servicetitan/install` package performs a single task and runs quickly.
|
|
22
|
+
And because it has no runtime dependencies, also eliminates risks from third-party changes.
|
|
23
|
+
:::
|
|
24
|
+
|
|
25
|
+
## Options
|
|
26
|
+
|
|
27
|
+
| Option | Description |
|
|
28
|
+
| :----------- | :----------------------------------------------------------------------- |
|
|
29
|
+
| `--no-token` | Only install dependencies. Don't configure the npm authentication token. |
|
|
30
|
+
| `--token` | Only configure the npm authentication token. Don't install dependencies. |
|
|
31
|
+
|
|
32
|
+
## Configuring NPM Token in Development
|
|
33
|
+
|
|
34
|
+
In development environments, `@servicetitan/install` automatically configures an npm authentication token that grants access to private ServiceTitan packages. It securely retrieves the token and updates your npm configuration so you can install dependencies without any further setup.
|
|
35
|
+
|
|
36
|
+
:::caution
|
|
37
|
+
`@servicetitan/install` detects if it is running in development by checking for standard environment variables set by CI systems (e.g.,`CI` and `TEAMCITY_VERSION`). If none of these variables are set, it assumes it is running on a developer machine.
|
|
38
|
+
If it mistakes a CI environment for a developer machine, add a `CI` environment variable (with any value) to the workflow, or [use `--no-token`](#how-to-use---no-token) to disable configuring the npm token.
|
|
39
|
+
:::
|
|
40
|
+
|
|
41
|
+
## Configuring NPM Token in CI
|
|
42
|
+
|
|
43
|
+
In CI environments such as Teamcity and Github, use the `ST_NPM_READONLY_TOKEN` organization secret to grant access to private ServiceTitan packages. You can do this in two ways:
|
|
44
|
+
|
|
45
|
+
### Option 1: Inject into .npmrc (Recommended)
|
|
46
|
+
|
|
47
|
+
The recommended method is to use `npm config set --location=project` to manually inject the organization secret into the project's `.npmrc`. For example,
|
|
48
|
+
|
|
49
|
+
<Tabs
|
|
50
|
+
defaultValue="github"
|
|
51
|
+
values={[{ label: "Github Action", value: "github"}, {label: "Dockerfile", value: "docker"}]}>
|
|
52
|
+
|
|
53
|
+
<TabItem value="github">
|
|
54
|
+
|
|
55
|
+
```yml
|
|
56
|
+
- run: npm config set --location=project "//registry.npmjs.org/:_authToken"="${{ secrets.ST_NPM_READONLY_TOKEN }}"
|
|
57
|
+
- run: npm run build
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Alternatively, in Github actions using `action/setup-node`, you can use `registry-url` and `env.NODE_AUTH_TOKEN` to have it configure the project level `.npmrc`. For example,
|
|
61
|
+
|
|
62
|
+
```yml
|
|
63
|
+
- uses: actions/setup-node@v4
|
|
64
|
+
registry-url: https://registry.npmjs.org
|
|
65
|
+
env:
|
|
66
|
+
NODE_AUTH_TOKEN: ${{ secrets.ST_NPM_READONLY_TOKEN }}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
</TabItem>
|
|
70
|
+
<TabItem value="docker">
|
|
71
|
+
|
|
72
|
+
```dockerfile
|
|
73
|
+
ARG ST_NPM_READONLY_TOKEN
|
|
74
|
+
|
|
75
|
+
RUN npm config set --location=project "//registry.npmjs.org/:_authToken=$ST_NPM_READONLY_TOKEN"
|
|
76
|
+
RUN npm run build
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
</TabItem>
|
|
80
|
+
</Tabs>
|
|
81
|
+
|
|
82
|
+
### Option 2: Use environment variable
|
|
83
|
+
|
|
84
|
+
:::caution
|
|
85
|
+
Using an environment variable is not recommended because it requires [extra steps](#how-to-configure-without-install) in projects not using `@servicetitan/install`.
|
|
86
|
+
:::
|
|
87
|
+
|
|
88
|
+
To use an environment variable to configure the npm token, modify `.npmrc` to get the token from an environment variable,
|
|
89
|
+
|
|
90
|
+
```npmrc title=".npmrc"
|
|
91
|
+
//registry.npmjs.org/:_authToken=${ST_NPM_READONLY_TOKEN}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Then, in the CI action, set that environment variable to the organization secret. For example,
|
|
95
|
+
|
|
96
|
+
<Tabs
|
|
97
|
+
defaultValue="github"
|
|
98
|
+
values={[{ label: "Github Action", value: "github"}, {label: "Dockerfile", value: "docker"}]}>
|
|
99
|
+
|
|
100
|
+
<TabItem value="github">
|
|
101
|
+
|
|
102
|
+
```yml
|
|
103
|
+
- run: npm run build
|
|
104
|
+
env:
|
|
105
|
+
ST_NPM_READONLY_TOKEN: ${{ secrets.ST_NPM_READONLY_TOKEN }}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
</TabItem>
|
|
109
|
+
<TabItem value="docker">
|
|
110
|
+
|
|
111
|
+
```dockerfile
|
|
112
|
+
ARG ST_NPM_READONLY_TOKEN
|
|
113
|
+
|
|
114
|
+
ENV ST_NPM_READONLY_TOKEN=$ST_NPM_READONLY_TOKEN
|
|
115
|
+
|
|
116
|
+
RUN npm run build
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
</TabItem></Tabs>
|
|
120
|
+
|
|
121
|
+
## How to Configure Development Environment When Not Using Install {#how-to-configure-without-install}
|
|
122
|
+
|
|
123
|
+
:::note
|
|
124
|
+
These instructions are only for projects using [Option 2](#option-2-use-environment-variable) and that are not using `@servicetitan/install`.
|
|
125
|
+
:::
|
|
126
|
+
|
|
127
|
+
If your project is [using an environment variable](#option-2-use-environment-variable), and it isn't using `@servicetitan/install`, then developers must also defined the same environment variable manually. And they must repeat these steps each time the token is rotated,
|
|
128
|
+
|
|
129
|
+
1. Run `npx --yes @servicetitan/install@latest --token` to add the token to your per-user configuration.
|
|
130
|
+
2. Run `npm config get userconfig` to get the location of your per-user configuration file.
|
|
131
|
+
3. Find the token in the configuration file, on the line that starts `//registry.npmjs.org/:_authToken=`
|
|
132
|
+
4. Create a local environment variable with the token. Use the same variable name as in project's `.npmrc`.
|
|
133
|
+
|
|
134
|
+
:::tip
|
|
135
|
+
On MacOS you can accomplish steps 2 and 3 with this single command:
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
grep registry.npmjs.org < $(npm config get userconfig)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
:::
|
|
142
|
+
|
|
143
|
+
## How to Use --no-token
|
|
144
|
+
|
|
145
|
+
If `@servicetitan/install` mistakes your CI environment for a development machine and it isn't practical to add a `CI` environment variable to the workflow, use `--no-token` to instruct `@servicetitan/install` not to attempt to configure the npm token.
|
|
146
|
+
|
|
147
|
+
Create a `build:ci` script and accompanying pre script that runs `bootstrap` with `-- --no-token`:
|
|
148
|
+
|
|
149
|
+
```json title="package.json"
|
|
150
|
+
"scripts": {
|
|
151
|
+
"prebuild:ci": "npm run bootstrap -- --no-token",
|
|
152
|
+
"build:ci": "startup build"
|
|
153
|
+
},
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Then, call `build:ci` instead of `build` in the CI workflow:
|
|
157
|
+
|
|
158
|
+
```sh
|
|
159
|
+
npm run build:ci
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
:::note
|
|
163
|
+
This assumes you're using this recommended `bootstrap` script:
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
"scripts": {
|
|
167
|
+
"bootstrap": "npx --yes @servicetitan/install",
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
:::
|
package/docs/startup/install.mdx
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
title: install
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
:::danger
|
|
6
|
+
The `startup install` command is deprecated; please instead use [@servicetitan/install](../install).
|
|
7
|
+
|
|
8
|
+
As `@servicetitan/startup` grew more features, it became too large for simple bootstrapping. The
|
|
9
|
+
dedicated `@servicetitan/install` package performs a single task and runs quickly. And because it
|
|
10
|
+
has no runtime dependencies, also eliminates risks from third-party changes.
|
|
11
|
+
:::
|
|
12
|
+
|
|
5
13
|
import Tabs from '@theme/Tabs';
|
|
6
14
|
import TabItem from '@theme/TabItem';
|
|
7
15
|
|
package/docs/startup/review.mdx
CHANGED
|
@@ -167,7 +167,7 @@ For example, given:
|
|
|
167
167
|
}
|
|
168
168
|
```
|
|
169
169
|
|
|
170
|
-
It runs
|
|
170
|
+
It runs
|
|
171
171
|
|
|
172
172
|
```sh
|
|
173
173
|
npm pkg set cli.webpack.static.directory="src/public" -w packages/app
|
|
@@ -176,6 +176,27 @@ npm pkg delete cli.webpack.contentBase -w packages/app
|
|
|
176
176
|
|
|
177
177
|
---
|
|
178
178
|
|
|
179
|
+
### no-deprecated-startup-install
|
|
180
|
+
|
|
181
|
+
Detects when projects use the deprecated `@servicetitan/startup install` bootstrap script.
|
|
182
|
+
|
|
183
|
+
Previously, we suggested using `npx --yes @servicetitan/startup install` to bootstrap projects.
|
|
184
|
+
But as `@servicetitan/startup` grew more features, it became too large for simple bootstrapping.
|
|
185
|
+
|
|
186
|
+
The dedicated `@servicetitan/install` package performs a single task and runs quickly.
|
|
187
|
+
And because it has no runtime dependencies, eliminates risks from third‑party changes.
|
|
188
|
+
|
|
189
|
+
#### ✅ Autofix
|
|
190
|
+
|
|
191
|
+
This rule supports autofix.
|
|
192
|
+
It changes the bootstrap script to `npx --yes @servicetitan/install`.
|
|
193
|
+
|
|
194
|
+
It runs
|
|
195
|
+
|
|
196
|
+
```sh
|
|
197
|
+
npm pkg set scripts.bootstrap="npx --yes @servicetitan/install"
|
|
198
|
+
```
|
|
199
|
+
|
|
179
200
|
### no-direct-peer-dependencies
|
|
180
201
|
|
|
181
202
|
Detects when a package is listed as both a direct dependency and a peer dependency.
|
|
@@ -315,7 +336,7 @@ And,
|
|
|
315
336
|
}
|
|
316
337
|
```
|
|
317
338
|
|
|
318
|
-
It runs
|
|
339
|
+
It runs
|
|
319
340
|
|
|
320
341
|
```sh
|
|
321
342
|
npm pkg set "main"="dist/index.js" -w packages/lib
|
|
@@ -341,7 +362,7 @@ It adds the missing `react` or `react-dom` dependency, using the same version th
|
|
|
341
362
|
}
|
|
342
363
|
```
|
|
343
364
|
|
|
344
|
-
It runs
|
|
365
|
+
It runs
|
|
345
366
|
|
|
346
367
|
```sh
|
|
347
368
|
npm pkg set dependencies["react-dom"]="^18.3.1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/docs-uikit",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
"cli": {
|
|
17
17
|
"webpack": false
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "9ba97491f520e7b5914179aa061d1c3c3285079d"
|
|
20
20
|
}
|