Skip to content

Commit

Permalink
remove build command (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
gossi authored Oct 4, 2021
1 parent 2771693 commit 8eff274
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 200 deletions.
13 changes: 0 additions & 13 deletions src/build/config.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/build/index.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import BuildConfig from './build/config';
import GenerateConfig from './generate/config';
import SyncConfig from './sync/config';

Expand All @@ -13,9 +12,6 @@ export default interface TheemoConfig {
/** Config for the sync command */
sync?: SyncConfig;

/** Config for the build command */
build?: BuildConfig;

/** Config for the generate command */
generate?: GenerateConfig;
}
9 changes: 1 addition & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ async function main() {
await theemo.sync();
});

program
.command('build')
.description('runs the build of your token manager tool')
.action(() => {
theemo.build();
});

program
.command('generate')
.description('generates an adaptive CSS theme file')
Expand Down Expand Up @@ -66,7 +59,7 @@ export type { default as WriterConfig } from './sync/writer/config';
export type { default as GenerateConfig } from './generate/config';

// tools
export type { Tools, ReaderTool, WriterTool, BuilderTool } from './tools/tool';
export type { Tools, ReaderTool, WriterTool } from './tools/tool';
export type {
FigmaReaderConfig,
FigmaReferencerConfig,
Expand Down
55 changes: 0 additions & 55 deletions src/theemo.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,21 @@
import BuildConfig from './build/config';
import BuildCommand from './build/index';
import TheemoConfig from './config';
import GenerateConfig from './generate/config';
import GenerateCommand from './generate/index';
import SyncConfig from './sync/config';
import SyncCommand from './sync/index';
import { Tools } from './tools/tool';
import { requireFile } from './utils';

interface Package {
name: string;
dependencies: {
[key: string]: string;
};
devDependencies: {
[key: string]: string;
};
}

export default class Theemo {
private config: TheemoConfig;
private package: Package;

constructor() {
this.config = this.loadConfig();
this.package = this.loadPackage();
}

private loadConfig(): TheemoConfig {
return requireFile('theemo.js') as TheemoConfig;
}

private loadPackage(): Package {
return requireFile('package.json') as Package;
}

private detectBuildTool(): Tools {
const deps = {
...this.package.dependencies,
...this.package.devDependencies
};

if (Object.keys(deps).includes('style-dictionary')) {
return Tools.StyleDictionary;
}

return Tools.Unknown;
}

/**
* Executes the sync command
*
Expand All @@ -61,29 +29,6 @@ export default class Theemo {
}
}

/**
* Executes the build command
*
* @param config the config for build (if it cannot be auto-detected)
*/
async build(config?: BuildConfig): Promise<void> {
let usedConfig = config ?? this.config.build;

if (!usedConfig) {
const tool = this.detectBuildTool();
if (tool !== Tools.Unknown) {
usedConfig = {
tool
};
}
}

if (usedConfig) {
const command = new BuildCommand(usedConfig);
command.execute();
}
}

/**
* Executes the generate command
*
Expand Down
61 changes: 0 additions & 61 deletions src/tools/style-dictionary/builder.ts

This file was deleted.

10 changes: 2 additions & 8 deletions src/tools/style-dictionary/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import TokenCollection from '../../token-collection';
import ToolConfig from '../config';
import { BuilderTool, WriterTool } from '../tool';
import StyleDictionaryBuilder from './builder';
import { WriterTool } from '../tool';
import { StyleDictionaryConfig } from './config';
import StyleDictionaryWriter from './writer';

export default class StyleDictionary implements WriterTool, BuilderTool {
export default class StyleDictionary implements WriterTool {
private config: StyleDictionaryConfig;

constructor(config: ToolConfig) {
this.config = config as StyleDictionaryConfig;
}

build() {
const builder = new StyleDictionaryBuilder();
builder.build();
}

write(tokens: TokenCollection) {
const writer = new StyleDictionaryWriter(this.config.writer);
writer.write(tokens);
Expand Down
13 changes: 1 addition & 12 deletions src/tools/tool-factory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ToolConfig from './config';
import Figma from './figma';
import StyleDictionary from './style-dictionary';
import { BuilderTool, ReaderTool, Tools, WriterTool } from './tool';
import { ReaderTool, Tools, WriterTool } from './tool';
import UnknownTool from './unknown-tool';

export default class ToolFactory {
Expand All @@ -26,15 +26,4 @@ export default class ToolFactory {
return new UnknownTool();
}
}

static createBuilder(tool: Tools, config: ToolConfig): BuilderTool {
switch (tool) {
case Tools.StyleDictionary:
return new StyleDictionary(config);

case Tools.Unknown:
default:
return new UnknownTool();
}
}
}
15 changes: 0 additions & 15 deletions src/tools/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,3 @@ export interface WriterTool {
*/
write(tokens: TokenCollection): void;
}

/**
* This is for tools used during the `build` command and trigger the execution
* of that tool.
*
* @example
*
* Style Dictionary may be your builder tool and executes the build process
*/
export interface BuilderTool {
/**
* Executes the build of the tool
*/
build(): void;
}
10 changes: 2 additions & 8 deletions src/tools/unknown-tool.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import TokenCollection from '../token-collection';
import { ReaderTool, WriterTool, BuilderTool } from './tool';
import { ReaderTool, WriterTool } from './tool';

export default class UnknownTool
implements ReaderTool, WriterTool, BuilderTool
{
export default class UnknownTool implements ReaderTool, WriterTool {
async read() {
const tokens = await new TokenCollection();
return tokens;
}

build() {
// void implementation
}

write(_tokens: TokenCollection) {
// void implementation
}
Expand Down

0 comments on commit 8eff274

Please sign in to comment.