create-dta 0.0.0-stage → 2.0.1
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 +22 -0
- package/README.md +8 -2
- package/bin.js +45 -0
- package/package.json +37 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Figma
|
|
4
|
+
Copyright (c) 2026 Martin Preciado Prinz
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# create-dta
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
```sh
|
|
4
|
+
npm create dta
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Sets up [Design Token Authority](https://github.com/Fuasmattn/design-token-authority) in the current project: it installs `design-token-authority` as a dev dependency (with the package manager you ran it with), then runs `design-token-authority init`.
|
|
8
|
+
|
|
9
|
+
`npm create dta -- --yes` asks nothing. Without a `dta.config.*` it writes one for exported token files in `tokens/`; with a config it sets up `dta diff` with the detected answers, including the GitHub workflow files.
|
package/bin.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// `npm create dta` (and `pnpm create dta`, `yarn create dta`, `bun create dta`): installs
|
|
3
|
+
// design-token-authority in the project, with the package manager that ran this, then runs
|
|
4
|
+
// `design-token-authority init` (TICKET-090). The config init writes imports `defineConfig`
|
|
5
|
+
// from the package, so it must be installed for the config to load. Arguments pass through:
|
|
6
|
+
// `npm create dta -- --yes`.
|
|
7
|
+
import { execFileSync } from 'node:child_process'
|
|
8
|
+
import fs from 'node:fs'
|
|
9
|
+
import path from 'node:path'
|
|
10
|
+
|
|
11
|
+
const PACKAGE = 'design-token-authority'
|
|
12
|
+
const { version } = JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), 'utf8'))
|
|
13
|
+
const cwd = process.cwd()
|
|
14
|
+
|
|
15
|
+
/** Whether the project's package.json already depends on the package. */
|
|
16
|
+
function declared() {
|
|
17
|
+
try {
|
|
18
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'))
|
|
19
|
+
return Boolean(pkg.dependencies?.[PACKAGE] ?? pkg.devDependencies?.[PACKAGE])
|
|
20
|
+
} catch {
|
|
21
|
+
return false
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// `npm_config_user_agent` names the package manager that runs `create`: "pnpm/10.28.0 npm/? …".
|
|
26
|
+
const manager = /^(pnpm|yarn|bun)\//.exec(process.env.npm_config_user_agent ?? '')?.[1] ?? 'npm'
|
|
27
|
+
const ADD = {
|
|
28
|
+
npm: ['install', '--save-dev'],
|
|
29
|
+
pnpm: ['add', '-D'],
|
|
30
|
+
yarn: ['add', '--dev'],
|
|
31
|
+
bun: ['add', '-d'],
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
if (!declared()) {
|
|
36
|
+
const args = [...ADD[manager], `${PACKAGE}@^${version}`]
|
|
37
|
+
console.log(`Installing ${PACKAGE}: ${manager} ${args.join(' ')}`)
|
|
38
|
+
execFileSync(manager, args, { cwd, stdio: 'inherit', shell: process.platform === 'win32' })
|
|
39
|
+
}
|
|
40
|
+
const { runCli } = await import(PACKAGE)
|
|
41
|
+
process.exitCode = await runCli(['init', ...process.argv.slice(2)])
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error(error instanceof Error ? error.message : error)
|
|
44
|
+
process.exitCode = 1
|
|
45
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-dta",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "npm create dta: set up Design Token Authority in a project (runs design-token-authority init)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Martin Preciado Prinz",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Fuasmattn/design-token-authority.git",
|
|
10
|
+
"directory": "packages/create-dta"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/Fuasmattn/design-token-authority#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Fuasmattn/design-token-authority/issues"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=24.14.1"
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"create-dta": "./bin.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"bin.js"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"design-token-authority": "^2.0.1"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^24.12.2",
|
|
34
|
+
"typescript": "^5.1.6",
|
|
35
|
+
"vitest": "^4.1.2"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"typecheck": "tsc --noEmit"
|
|
39
|
+
}
|
|
6
40
|
}
|