@outwalk/create-firefly 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,11 +3,18 @@
3
3
 
4
4
  var yargs = require('yargs-parser');
5
5
  var prompts = require('prompts');
6
- var chalk = require('chalk');
7
6
  var path = require('path');
8
7
  var fs = require('fs');
8
+ var chalk = require('chalk');
9
9
  var child_process = require('child_process');
10
10
 
11
+ const firefly = chalk.hex("#ADFF2F");
12
+ const logger = {
13
+ log: (...message) => console.log(`${firefly("[firefly]")} - `, ...message),
14
+ warn: (...message) => console.log(`${chalk.yellow("[firefly]")} - `, ...message),
15
+ error: (...message) => console.log(`${chalk.red("[firefly]")} - `, ...message)
16
+ };
17
+
11
18
  class TemplateBuilder {
12
19
  constructor(src, dest) {
13
20
  this.src = src;
@@ -79,10 +86,9 @@ class TemplateBuilder {
79
86
  }
80
87
  }
81
88
 
82
- const firefly$1 = chalk.hex("#ADFF2F");
83
89
  function installDependencies(dependencies, directory) {
84
90
  return new Promise((resolve, reject) => {
85
- console.log(`${firefly$1("[firefly]")} - installing dependencies...`);
91
+ logger.log("installing dependencies...");
86
92
  const command = /^win/.test(process.platform) ? "npm.cmd" : "npm";
87
93
  const spawnProcess = (command2, args) => {
88
94
  const { status, error } = child_process.spawnSync(command2, args, { cwd: directory, stdio: "ignore" });
@@ -101,7 +107,7 @@ function installDependencies(dependencies, directory) {
101
107
  }
102
108
  function intitializeGitRepository(directory) {
103
109
  return new Promise((resolve, reject) => {
104
- console.log(`${firefly$1("[firefly]")} - initializing git repository...`);
110
+ logger.log("initializing git repository...");
105
111
  try {
106
112
  child_process.exec("git init", { cwd: directory });
107
113
  resolve();
@@ -111,7 +117,6 @@ function intitializeGitRepository(directory) {
111
117
  });
112
118
  }
113
119
 
114
- const firefly = chalk.hex("#ADFF2F");
115
120
  const args = yargs(process.argv.slice(2));
116
121
  prompts.override({
117
122
  name: args._[0],
@@ -186,12 +191,12 @@ const questions = [
186
191
  if (force && !settings.useCurrentDirectory) {
187
192
  TemplateBuilder.deleteDirectory(config.name);
188
193
  } else {
189
- console.error(`${chalk.red("[firefly]")} - ${config.name} already exists.`);
194
+ logger.error(`${config.name} already exists.`);
190
195
  return;
191
196
  }
192
197
  }
193
- console.log(`
194
- ${firefly("[firefly]")} - creating ${config.name}...`);
198
+ console.log("\n");
199
+ logger.log(`creating ${config.name}...`);
195
200
  const templatePath = path.join(__dirname, "../templates/", config.language);
196
201
  const snippetPath = path.join(__dirname, "../templates/snippets");
197
202
  const projectPath = !settings.useCurrentDirectory ? config.name : ".";
@@ -218,7 +223,7 @@ ${firefly("[firefly]")} - creating ${config.name}...`);
218
223
  }
219
224
  template.build();
220
225
  } catch (error) {
221
- console.error(`${chalk.red("[firefly]")} - ${error.message}`);
226
+ logger.error(error.message);
222
227
  return;
223
228
  }
224
229
  try {
@@ -227,7 +232,7 @@ ${firefly("[firefly]")} - creating ${config.name}...`);
227
232
  if (!skipGit)
228
233
  await intitializeGitRepository(projectPath);
229
234
  } catch (error) {
230
- console.error(`${chalk.red("[firefly]")} - ${error.message}`);
235
+ logger.error(error.message);
231
236
  if (!settings.useCurrentDirectory)
232
237
  TemplateBuilder.deleteDirectory(config.name);
233
238
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outwalk/create-firefly",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Firefly - a modern scalable web framework.",
5
5
  "main": "dist/index.js",
6
6
  "publishConfig": {
@@ -0,0 +1,10 @@
1
+ import { Controller, Get } from "@outwalk/firefly";
2
+
3
+ @Controller()
4
+ export class IndexController {
5
+
6
+ @Get()
7
+ getHelloWorld() {
8
+ return "Hello World!";
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ import { Controller, Get } from "@outwalk/firefly";
2
+
3
+ @Controller()
4
+ export class AppController {
5
+
6
+ @Get()
7
+ getHelloWorld(): string {
8
+ return "Hello World!";
9
+ }
10
+ }
@@ -1,12 +0,0 @@
1
- import { Controller, Inject, Get } from "@outwalk/firefly";
2
-
3
- @Controller()
4
- export class AppController {
5
-
6
- @Inject() appService;
7
-
8
- @Get()
9
- getHelloWorld() {
10
- return this.appService.getHelloWorld();
11
- }
12
- }
@@ -1,9 +0,0 @@
1
- import { Injectable } from "@outwalk/firefly";
2
-
3
- @Injectable()
4
- export class AppService {
5
-
6
- getHelloWorld() {
7
- return "Hello World!";
8
- }
9
- }
@@ -1,14 +0,0 @@
1
- import { Controller, Inject, Get } from "@outwalk/firefly";
2
- import { AppService } from "./app.service";
3
-
4
- @Controller()
5
- export class AppController {
6
-
7
- @Inject()
8
- appService: AppService;
9
-
10
- @Get()
11
- getHelloWorld(): string {
12
- return this.appService.getHelloWorld();
13
- }
14
- }
@@ -1,9 +0,0 @@
1
- import { Injectable } from "@outwalk/firefly";
2
-
3
- @Injectable()
4
- export class AppService {
5
-
6
- getHelloWorld(): string {
7
- return "Hello World!";
8
- }
9
- }