disable wip snippets
This commit is contained in:
		| @@ -6,5 +6,6 @@ | ||||
|  */ | ||||
|  | ||||
| export interface Snippet { | ||||
|   is_active(): boolean; | ||||
|   start(cwd: string): Promise<void>; | ||||
| } | ||||
|   | ||||
							
								
								
									
										25
									
								
								lib/index.ts
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								lib/index.ts
									
									
									
									
									
								
							| @@ -12,17 +12,22 @@ import { Snippet } from './Snippet'; | ||||
|  | ||||
| (async (): Promise<void> => { | ||||
|   const snippets = await fs.readdir (path.join (__dirname, 'snippets')); | ||||
|   const snippet = await new AutoComplete ( | ||||
|     { | ||||
|       name:    'snippet', | ||||
|       message: 'choose a snippet', | ||||
|       choices: snippets | ||||
|     } | ||||
|   ) | ||||
|   const runners: Record<string, Snippet> = {}; | ||||
|   await Promise.all ( | ||||
|     snippets.map (async (s) => { | ||||
|       const runner = (new ( | ||||
|         await import (`./snippets/${s}/index.js`) | ||||
|       ).default) as Snippet; | ||||
|       runners[s] = runner; | ||||
|     }) | ||||
|   ); | ||||
|   const snippet = await new AutoComplete ({ | ||||
|     name:    'snippet', | ||||
|     message: 'choose a snippet', | ||||
|     choices: snippets.filter ((s) => runners[s].is_active ()) | ||||
|   }) | ||||
|     .run (); | ||||
|   const runner | ||||
|   = new (await import (`./snippets/${snippet}/index.js`)).default as Snippet; | ||||
|   runner.start (process.cwd ()); | ||||
|   runners[snippet].start (process.cwd ()); | ||||
| }) () | ||||
|   // eslint-disable-next-line no-console | ||||
|   .catch ((e) => console.log (e)); | ||||
|   | ||||
| @@ -19,6 +19,10 @@ import { FileMapper } from './file_mapper'; | ||||
| import { CopyrightOptions } from './copyright_options'; | ||||
|  | ||||
| export default class Copyright implements Snippet { | ||||
|   public is_active (): boolean { | ||||
|     return true; | ||||
|   } | ||||
|  | ||||
|   private _options: CopyrightOptions | null = null; | ||||
|   private _cwd = ''; | ||||
|   private _loaded_from_config = false; | ||||
|   | ||||
| @@ -8,7 +8,11 @@ | ||||
| import { Snippet } from '../../Snippet'; | ||||
|  | ||||
| export default class Database implements Snippet { | ||||
|   public is_active (): boolean { | ||||
|     return false; | ||||
|   } | ||||
|  | ||||
|   public start (): Promise<void> { | ||||
|     return new Promise ((res) => res ()); | ||||
|     return Promise.resolve (); | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -12,6 +12,10 @@ import { apply_template, modify_json } from '../../Helper'; | ||||
| import { general, node } from './Assets'; | ||||
|  | ||||
| export default class Jenkins implements Snippet { | ||||
|   public is_active (): boolean { | ||||
|     return true; | ||||
|   } | ||||
|  | ||||
|   public async start (): Promise<void> { | ||||
|     const is_node = await new Confirm ({ | ||||
|       message: 'is the current project using nodejs?', | ||||
|   | ||||
| @@ -56,6 +56,10 @@ async function init_package ( | ||||
| } | ||||
|  | ||||
| export default class Node implements Snippet { | ||||
|   public is_active (): boolean { | ||||
|     return true; | ||||
|   } | ||||
|  | ||||
|   public async start (): Promise<void> { | ||||
|     const folder = await new Input ( | ||||
|       { message: 'project name (leave empty for current folder):' } | ||||
|   | ||||
| @@ -4,6 +4,10 @@ import { modify_json, apply_template } from '../../Helper'; | ||||
| import { get_readme } from './Assets'; | ||||
|  | ||||
| export default class Readme implements Snippet { | ||||
|   public is_active (): boolean { | ||||
|     return true; | ||||
|   } | ||||
|  | ||||
|   public async start (): Promise<void> { | ||||
|     const dev = await new Confirm ({ | ||||
|       message: 'is the package used as dev dependency?', | ||||
|   | ||||
		Reference in New Issue
	
	Block a user