MCPcopy Index your code
hub / github.com/nodejs/node / create

Method create

deps/npm/lib/commands/token.js:152–241  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

150 }
151
152 async create () {
153 const json = this.npm.config.get('json')
154 const parseable = this.npm.config.get('parseable')
155 const cidr = this.npm.config.get('cidr')
156 const name = this.npm.config.get('name')
157 const tokenDescription = this.npm.config.get('token-description')
158 const expires = this.npm.config.get('expires')
159 const packages = this.npm.config.get('packages')
160 const packagesAll = this.npm.config.get('packages-all')
161 const scopes = this.npm.config.get('scopes')
162 const orgs = this.npm.config.get('orgs')
163 const packagesAndScopesPermission = this.npm.config.get('packages-and-scopes-permission')
164 const orgsPermission = this.npm.config.get('orgs-permission')
165 const bypassTwoFactor = this.npm.config.get('bypass-2fa')
166 let password = this.npm.config.get('password')
167
168 const validCIDR = await this.validateCIDRList(cidr)
169
170 /* istanbul ignore if - skip testing read input */
171 if (!password) {
172 password = await readUserInfo.password()
173 }
174
175 const tokenData = {
176 name: name,
177 password: password,
178 }
179
180 if (tokenDescription) {
181 tokenData.description = tokenDescription
182 }
183
184 if (packages?.length > 0) {
185 tokenData.packages = packages
186 }
187 if (packagesAll) {
188 tokenData.packages_all = true
189 }
190 if (scopes?.length > 0) {
191 tokenData.scopes = scopes
192 }
193 if (orgs?.length > 0) {
194 tokenData.orgs = orgs
195 }
196
197 if (packagesAndScopesPermission) {
198 tokenData.packages_and_scopes_permission = packagesAndScopesPermission
199 }
200 if (orgsPermission) {
201 tokenData.orgs_permission = orgsPermission
202 }
203
204 // Add expiration in days
205 if (expires) {
206 tokenData.expires = parseInt(expires, 10)
207 }
208
209 // Add optional fields

Callers 1

execMethod · 0.95

Calls 11

validateCIDRListMethod · 0.95
otpleaseFunction · 0.85
passwordMethod · 0.80
infoMethod · 0.80
getMethod · 0.65
jsonMethod · 0.65
forEachMethod · 0.65
keysMethod · 0.65
bufferMethod · 0.45
greenMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected