-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TypeScript to 'cli' package (#33)
- Loading branch information
1 parent
f32488f
commit 61dbc14
Showing
17 changed files
with
126 additions
and
2,007 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Command } from '@oclif/command'; | ||
|
||
import * as figmaExport from '@figma-export/core'; | ||
|
||
import fs = require('fs'); | ||
import path = require('path'); | ||
import ora = require('ora'); | ||
|
||
type FigmaExportCommand = [string, {}]; | ||
|
||
const spinner = ora({}); | ||
|
||
class UseConfigCommand extends Command { | ||
async run(): Promise<void> { | ||
const { | ||
args: { | ||
config, | ||
}, | ||
} = this.parse(UseConfigCommand); | ||
|
||
const configPath = path.resolve(config); | ||
|
||
// eslint-disable-next-line import/no-dynamic-require, global-require | ||
const { commands = [] } = fs.existsSync(configPath) ? require(configPath) : {}; | ||
|
||
Promise.all(commands.map((command: FigmaExportCommand) => { | ||
const [commandName, options] = command; | ||
|
||
spinner.start(); | ||
|
||
let figmaExporter; | ||
switch (commandName) { | ||
case 'components': | ||
figmaExporter = figmaExport.components; | ||
break; | ||
default: | ||
throw new Error(`Command ${commandName} is not found.`); | ||
} | ||
|
||
return figmaExporter({ | ||
token: process.env.FIGMA_TOKEN || '', | ||
...options, | ||
log: (message: string) => { spinner.text = message; }, | ||
}).then(() => { | ||
spinner.stop(); | ||
}).catch((err: Error) => { | ||
spinner.stop(); | ||
this.error(err, { exit: 1 }); | ||
}); | ||
})); | ||
} | ||
} | ||
|
||
UseConfigCommand.description = `export using a configuration file | ||
`; | ||
|
||
UseConfigCommand.args = [ | ||
{ | ||
name: 'config', | ||
default: '.figmaexportrc.js', | ||
required: true, | ||
}, | ||
]; | ||
|
||
module.exports = UseConfigCommand; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { run } from '@oclif/command'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "dist" | ||
}, | ||
"references": [ | ||
{"path": "../core"}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,5 @@ | |
}, | ||
"references": [ | ||
{"path": "../types"}, | ||
{"path": "../output-components-utils"}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,5 @@ | |
}, | ||
"references": [ | ||
{"path": "../types"}, | ||
{"path": "../output-components-utils"}, | ||
] | ||
} |