-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(general): first public release (#26)
* chore(develop): release 1.1.0 (#5) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat(export): add collector export (#17) * feat(export): add export collectors * chore(export): add platform param * refactor(export): rename function Co-authored-by: d-pettersson <[email protected]> * fix(general): refactor build script (#18) (#19) * feat(export): refactor code to allow for options (#21) * fix(export): refactor code to allow for options * feat(export): added 8bidou typed * chore(develop): release 1.2.0 (#24) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat(templates): adding template engine (#25) * feat: add template submodules * chore: updated submodules * chore: removed submodule * chore(general): refactor to include ncc * chore: finalise templates * chore: add missing files * chore(general): cleanup * chore: cleanup * chore: add eslint and prettier Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: somaticbits <[email protected]> Co-authored-by: d-pettersson <[email protected]>
- Loading branch information
1 parent
2675696
commit 7d7d4cb
Showing
21 changed files
with
3,857 additions
and
3,520 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
node_modules | ||
bin | ||
bin |
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 |
---|---|---|
|
@@ -3,4 +3,4 @@ bin | |
.yarn-error.log | ||
package-lock.json | ||
*.csv | ||
.idea | ||
.idea |
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,4 @@ | ||
.github | ||
.husky | ||
bin/ | ||
tsconfig.json |
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,20 +1,28 @@ | ||
# Changelog | ||
|
||
## [1.1.0](https://github.com/versumstudios/cli/compare/v1.0.0...v1.1.0) (2022-07-23) | ||
|
||
## [1.2.0](https://github.com/versumstudios/cli/compare/v1.1.0...v1.2.0) (2022-07-28) | ||
|
||
### Features | ||
|
||
* **export:** add export token ([#3](https://github.com/versumstudios/cli/issues/3)) ([#4](https://github.com/versumstudios/cli/issues/4)) ([864f0f8](https://github.com/versumstudios/cli/commit/864f0f8a423938715e9331e6f458c422ab27a165)) | ||
- **export:** add collector export ([#17](https://github.com/versumstudios/cli/issues/17)) ([f721109](https://github.com/versumstudios/cli/commit/f7211096b77789a14c9d4b4714b59ff3ac56fc68)) | ||
- **export:** refactor code to allow for options ([#21](https://github.com/versumstudios/cli/issues/21)) ([d366593](https://github.com/versumstudios/cli/commit/d366593be3495d301f8c44362a1be1a78c25f333)) | ||
|
||
## 1.0.0 (2022-07-23) | ||
### Bug Fixes | ||
|
||
- **general:** refactor build script ([#18](https://github.com/versumstudios/cli/issues/18)) ([#19](https://github.com/versumstudios/cli/issues/19)) ([d1bde54](https://github.com/versumstudios/cli/commit/d1bde54a7e539bc23bceb11cc1574ddb9fd9b068)) | ||
|
||
## [1.1.0](https://github.com/versumstudios/cli/compare/v1.0.0...v1.1.0) (2022-07-23) | ||
|
||
### Features | ||
|
||
* **General:** initial commit ([7d30491](https://github.com/versumstudios/cli/commit/7d3049152d19ce89fc0c7513ebb7243f017ebf47)) | ||
- **export:** add export token ([#3](https://github.com/versumstudios/cli/issues/3)) ([#4](https://github.com/versumstudios/cli/issues/4)) ([864f0f8](https://github.com/versumstudios/cli/commit/864f0f8a423938715e9331e6f458c422ab27a165)) | ||
|
||
## 1.0.0 (2022-07-23) | ||
|
||
### Features | ||
|
||
- **General:** initial commit ([7d30491](https://github.com/versumstudios/cli/commit/7d3049152d19ce89fc0c7513ebb7243f017ebf47)) | ||
|
||
### Miscellaneous | ||
|
||
* add github issue templates ([49e3489](https://github.com/versumstudios/cli/commit/49e3489c1259215ad88acb68f8742aad6982e853)) | ||
- add github issue templates ([49e3489](https://github.com/versumstudios/cli/commit/49e3489c1259215ad88acb68f8742aad6982e853)) |
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
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,116 @@ | ||
import fs from 'fs'; | ||
import inquirer from 'inquirer'; | ||
import fetch from 'node-fetch'; | ||
import ora from 'ora'; | ||
|
||
import { ERRORS, MESSAGES } from '../constants'; | ||
import { GithubProps } from '../types'; | ||
import { copyDirectoy, deleteDirectory, makeDirectory, parseFiles } from '../utils/filesystem'; | ||
import { downloadAndExtractRepo } from '../utils/github'; | ||
import { error, info } from '../utils/logger'; | ||
|
||
const DEFAULT_NAME = 'my-app'; | ||
const DEFAULT_DESCRIPTION = '@versumstudios/cli template'; | ||
|
||
const GITHUB_USER = 'versumstudios'; | ||
const GITHUB_REPO = 'templates'; | ||
const GITHUB_BRANCH = 'main'; | ||
|
||
const handleAction = async ( | ||
template: string, | ||
name: string = DEFAULT_NAME, | ||
description: string = DEFAULT_DESCRIPTION | ||
) => { | ||
const now = Date.now(); | ||
|
||
const appName = name.replace(/\s+/g, '-').toLowerCase(); | ||
const appDescription = description.toLowerCase(); | ||
|
||
const rootDir = process.cwd(); | ||
const tempDir = `${rootDir}/temp`; | ||
const templateDir = `${tempDir}/${template}`; | ||
const targetDir = `${rootDir}/${appName}`; | ||
|
||
if (fs.existsSync(targetDir)) { | ||
throw new Error('Directory already exists'); | ||
} | ||
|
||
await makeDirectory(tempDir); | ||
|
||
await downloadAndExtractRepo(tempDir, { | ||
username: GITHUB_USER, | ||
name: GITHUB_REPO, | ||
branch: GITHUB_BRANCH, | ||
}); | ||
|
||
await copyDirectoy(templateDir, targetDir); | ||
|
||
await deleteDirectory(tempDir); | ||
|
||
await parseFiles(targetDir, appName, appDescription); | ||
|
||
return `"${template}" template created in ${Date.now() - now}ms`; | ||
}; | ||
|
||
export const action = async (options: Record<string, string>) => { | ||
// if options are present, bypass the user promp | ||
if (options.template) { | ||
handleAction(options.template) | ||
.then((message) => info(message)) | ||
.catch((e) => { | ||
error(e?.toString() || ERRORS.ERROR_GENERATE_TEMPLATE); | ||
}); | ||
return; | ||
} | ||
|
||
// gets a list of all templates | ||
const result = await fetch(`https://api.github.com/repos/${GITHUB_USER}/${GITHUB_REPO}/git/trees/${GITHUB_BRANCH}`); | ||
const { tree } = await result.json(); | ||
|
||
if (!tree) { | ||
throw new Error(ERRORS.ERROR_EXPORT_COLLECTOR); | ||
} | ||
|
||
// filter list to only return folders | ||
const choices = tree.filter((e: GithubProps) => e.type === 'tree').map((e: GithubProps) => e.path); | ||
|
||
// pass the templates into inquirer | ||
const questions = [ | ||
{ | ||
type: 'input', | ||
name: 'name', | ||
message: MESSAGES.ENTER_PROJECT_NAME, | ||
default() { | ||
return DEFAULT_NAME; | ||
}, | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'description', | ||
message: MESSAGES.ENTER_PROJECT_DESCRIPTION, | ||
default() { | ||
return DEFAULT_DESCRIPTION; | ||
}, | ||
}, | ||
{ | ||
type: 'list', | ||
name: 'template', | ||
message: MESSAGES.SELECT_TEMPLATE, | ||
choices, | ||
}, | ||
]; | ||
|
||
inquirer.prompt(questions).then(({ template, name, description }: Record<string, string>) => { | ||
const spinner = ora(MESSAGES.GENERATE_TEMPLATE).start(); | ||
|
||
handleAction(template, name, description) | ||
.then((message: string) => { | ||
spinner.succeed(); | ||
info(message); | ||
}) | ||
.catch((e) => { | ||
spinner.fail(); | ||
error(e?.toString() || ERRORS.ERROR_GENERATE_TEMPLATE); | ||
}); | ||
}); | ||
}; |
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,20 +1,20 @@ | ||
import { Command } from 'commander'; | ||
|
||
import { action as exportTokenCollectorsAction } from '@actions/export-token-collectors'; | ||
import { action as exportCollectorsAction } from '@actions/export-wallet-collectors'; | ||
|
||
export const command = new Command('export').description('export token data to csv'); | ||
import { action as exportTokenCollectorsAction } from '../actions/export-token-collectors'; | ||
import { action as exportCollectorsAction } from '../actions/export-wallet-collectors'; | ||
|
||
const command = new Command('export').description('export token data to csv'); | ||
command | ||
.command('token-collectors') | ||
.description('exports token collectors') | ||
.option('-c, --contract <value>', 'contract address') | ||
.option('-t, --token <value>', 'token id') | ||
.action(exportTokenCollectorsAction); | ||
|
||
command | ||
.command('wallet-collectors') | ||
.description('exports wallet collectors') | ||
.option('-w, --wallet <value>', 'user wallet address') | ||
.option('-p, --platform <value>', 'platform') | ||
.action(exportCollectorsAction); | ||
|
||
export default 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,11 @@ | ||
import { Command } from 'commander'; | ||
|
||
import { action as templateAction } from '../actions/template'; | ||
|
||
const command = new Command() | ||
.command('template') | ||
.description('creates a new project from a template') | ||
.option('-t, --template <value>', 'specify a template') | ||
.action(templateAction); | ||
|
||
export default 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { Command } from 'commander'; | ||
|
||
import { action as testAction } from '@actions/test'; | ||
import { action as testAction } from '../actions/test'; | ||
|
||
export const command = new Command().command('test').description('test description').action(testAction); | ||
const command = new Command().command('test').description('test description').action(testAction); | ||
export default command; |
Oops, something went wrong.