Skip to content

Commit

Permalink
feat: add the @digir/create-tokens CLI tool
Browse files Browse the repository at this point in the history
  • Loading branch information
unekinn committed Jun 18, 2024
1 parent b76375f commit b645276
Show file tree
Hide file tree
Showing 27 changed files with 4,599 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/create-tokens/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
root: false,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
};
5 changes: 5 additions & 0 deletions packages/create-tokens/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

import { require } from 'tsx/cjs/api';

require('./src/bin/create-tokens.ts', import.meta.url);
33 changes: 33 additions & 0 deletions packages/create-tokens/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@digdir/create-tokens",
"version": "0.1.0-alpha.7",
"description": "CLI tool to create an initial token structure for Designsystemet",
"author": "Designsystemet team",
"repository": {
"type": "git",
"url": "git+https://github.com/digdir/designsystemet.git"
},
"homepage": "https://github.com/digdir/designsystemet/tree/main/packages/create-tokens",
"license": "MIT",
"type": "module",
"publishConfig": {
"access": "public"
},
"main": "index.js",
"bin": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"@commander-js/extra-typings": "^12.0.1",
"change-case": "^5.3.0",
"commander": "^12.0.0",
"kleur": "^3.0.3",
"prompts": "^2.4.0",
"tsx": "^4.11.2"
},
"devDependencies": {
"@tokens-studio/types": "^0.4.0",
"@types/prompts": "^2.4.9"
}
}
21 changes: 21 additions & 0 deletions packages/create-tokens/src/bin/create-tokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Argument, program } from '@commander-js/extra-typings';

import { createTokensPackage } from '../createTokensPackage';

program
.name('npm create @digdir/tokens')
.description(
'CLI tool to create an initial token structure for Designsystemet',
);

program
.addArgument(
new Argument('<targetDir>', 'Target directory for the generated code'),
)
.action(async (targetDir) => {
await createTokensPackage(targetDir);
});

program.showHelpAfterError();

void program.parseAsync(process.argv);
Loading

0 comments on commit b645276

Please sign in to comment.