-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add templates generation (#207)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
c361883
commit d6415ed
Showing
8 changed files
with
98 additions
and
30 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# Generated by Shelve CLI | ||
SHELVE_TOKEN=your_value | ||
TEST=your_value | ||
SHELVE_URL=your_value | ||
TEST=your_value |
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,46 @@ | ||
import fs from 'fs' | ||
import { addDevDependency } from 'nypm' | ||
import { spinner, confirm, isCancel, note, intro } from '@clack/prompts' | ||
import { onCancel } from './index' | ||
|
||
const s = spinner() | ||
|
||
const templates = { | ||
eslint: 'https://raw.githubusercontent.com/HugoRCD/templates/main/eslint.config.js' | ||
} | ||
|
||
export async function getEslintConfig(): Promise<void> { | ||
intro('Generate ESLint config') | ||
|
||
s.start('Fetching ESLint config') | ||
|
||
try { | ||
const response = await fetch(templates.eslint) | ||
const text = await response.text() | ||
|
||
fs.writeFileSync('./eslint.config.js', text) | ||
|
||
s.stop('Fetching ESLint config') | ||
|
||
note('ESLint config has been generated', 'ESLint config') | ||
|
||
const install = await confirm({ | ||
message: 'Do you want to install ESLint and @hrcd/eslint-config?' | ||
}) | ||
|
||
if (isCancel(install)) onCancel('Operation cancelled.') | ||
|
||
if (install) { | ||
s.start('Installing eslint and @hrcd/eslint-config') | ||
await addDevDependency('eslint', { | ||
silent: true | ||
}) | ||
await addDevDependency('@hrcd/eslint-config', { | ||
silent: true | ||
}) | ||
s.stop('Installing ESLint and @hrcd/eslint-config') | ||
} | ||
} catch (error) { | ||
onCancel('Failed to fetch ESLint config') | ||
} | ||
} |