Skip to content

Commit

Permalink
refactor: add new assets and init with examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ipetinate committed Jun 21, 2024
1 parent f780e4e commit 7b03e13
Show file tree
Hide file tree
Showing 22 changed files with 231 additions and 330 deletions.
18 changes: 0 additions & 18 deletions .clingon/presets/generator.json

This file was deleted.

18 changes: 0 additions & 18 deletions .clingon/presets/util.json

This file was deleted.

114 changes: 0 additions & 114 deletions .clingon/templates/README.md

This file was deleted.

13 changes: 0 additions & 13 deletions .clingon/templates/component/Component.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions .clingon/templates/docs/ReactHookDoc.md

This file was deleted.

41 changes: 0 additions & 41 deletions .clingon/templates/meta.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions clingon.config.json

This file was deleted.

11 changes: 4 additions & 7 deletions src/actions/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
checkIfTemplateFolderAlreadyExists,
createFileIfNotExists,
createPresetFolderIfNotExists,
createPresetsFolderAssets,
createTemplateFolderAssets,
createTemplateFolderIfNotExists,
getConfigContent,
getConfigFilePath
} from '../utils/init-action.js'

Expand All @@ -19,19 +19,16 @@ export async function initAction(options) {
* Global Config
*/

compose(
getConfigFilePath(options.examples),
createFileIfNotExists,
getConfigContent
)
compose(getConfigFilePath(options.examples), createFileIfNotExists)

/*
* Preset Folder
*/

compose(
checkIfPresetFolderAlreadyExists(options.examples),
createPresetFolderIfNotExists
createPresetFolderIfNotExists,
createPresetsFolderAssets
)

/*
Expand Down
44 changes: 44 additions & 0 deletions src/constants/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export const templateCoreFiles = [
{
folder: 'templates/core/functions',
target: 'functions',
files: ['AsyncFunction.ts', 'AsyncFunction.spec.ts']
},
{
folder: 'templates/core/markdown',
target: 'docs',
files: ['HookDoc.md']
},
{
folder: 'templates/core/react-component',
target: 'component/react-component',
files: [
'index.tsx',
'Component.tsx',
'Component.test.tsx',
'Component.styles.css',
'Component.stories.tsx'
]
},
{
folder: 'templates/core',
target: '',
files: ['meta.yaml', 'SCAFFOLD_GUIDE.md']
}
]

export const presetsCoreFiles = [
{
folder: 'templates/core',
target: '',
files: ['PRESETS_GUIDE.md', 'function-preset.json']
}
]

export const globalCoreFiles = [
{
folder: 'templates/core',
target: '',
files: ['clingon.config.json']
}
]
12 changes: 9 additions & 3 deletions src/flows/coldStart.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { join } from 'node:path'
import { readFileContent } from '../utils/file.js'
import { getConfigContent } from '../utils/init-action.js'
import { checkFileExists, readFileContent } from '../utils/file.js'

export async function coldStart() {
const configPath = join(process.cwd(), 'clingon.config.json')
Expand All @@ -16,7 +15,14 @@ export async function coldStart() {
}

try {
data.globalConfig = getConfigContent(configPath)
const exists = checkFileExists(configPath)

if (!exists) return { globalConfig: null }

const fileContent = readFileContent(configPath)
const fileContentParsed = JSON.parse(fileContent)

data.globalConfig = fileContentParsed
} catch (error) {
console.error(error)
}
Expand Down
6 changes: 6 additions & 0 deletions src/templates/core/clingon.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"alias": {
"src": "@"
},
"exportDefault": false
}
18 changes: 0 additions & 18 deletions src/templates/core/global-config.js

This file was deleted.

27 changes: 27 additions & 0 deletions src/templates/core/markdown/HookDoc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ResourceName

> My hook doc
## Introduction

> Describe below about your hook
- ...

## How to use

> Describe below how to use your hook
- ...

## Examples

> Add useful examples of code
- ...

```ts
// code examples

const hookData = useResourceName()
```
Loading

0 comments on commit 7b03e13

Please sign in to comment.