at-builder 1.0.10 → 1.0.11

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/bin/index.js CHANGED
@@ -5,6 +5,20 @@ const child_process_1 = require("child_process");
5
5
  const config_1 = require("./constants/config");
6
6
  const path = require("path");
7
7
  const fs = require("fs");
8
+ const readline = require('readline');
9
+ // inquirer
10
+ // .prompt([
11
+ // ])
12
+ // .then((answers) => {
13
+ // // Use user feedback for... whatever!!
14
+ // })
15
+ // .catch((error) => {
16
+ // if (error.isTtyError) {
17
+ // // Prompt couldn't be rendered in the current environment
18
+ // } else {
19
+ // // Something else went wrong
20
+ // }
21
+ // });
8
22
  try {
9
23
  fs.accessSync(path.join(process.cwd(), ".env"), fs.constants.R_OK);
10
24
  }
@@ -16,10 +30,13 @@ commander
16
30
  .version("1.0.0", "-v, --version")
17
31
  .usage("[OPTIONS]...")
18
32
  .option("-c, --command <value>")
33
+ .option("-p, --prod")
19
34
  .parse(process.argv);
20
35
  const options = commander.opts();
36
+ let userChoice = '';
21
37
  var productionEnv = Object.create(process.env);
22
38
  productionEnv.executionPath = process.cwd();
39
+ console.log("OPTIONS COmmand", options.command);
23
40
  switch (options.command) {
24
41
  case "new": {
25
42
  (0, child_process_1.spawn)("npm", ["run", "new-activity"], {
@@ -32,12 +49,45 @@ switch (options.command) {
32
49
  break;
33
50
  }
34
51
  case "build": {
35
- (0, child_process_1.spawn)("npm", ["run", "dev"], {
36
- cwd: path.join(__dirname, "../"),
37
- env: productionEnv,
38
- shell: true,
39
- stdio: "inherit",
40
- });
52
+ if (options.prod) {
53
+ process.env['NODE_ENV'] = 'production';
54
+ }
55
+ if (!options.prod) {
56
+ const rl = readline.createInterface({
57
+ input: process.stdin,
58
+ output: process.stdout
59
+ });
60
+ rl.question('Do you want open your build in a browser tab: Y/N ? ', function (ans) {
61
+ console.log(`ANSWER ${ans}`);
62
+ userChoice = ans;
63
+ rl.close();
64
+ });
65
+ rl.on('close', function () {
66
+ const commandArr = ['run', 'dev'];
67
+ if (userChoice !== 'Y' && userChoice !== 'N') {
68
+ return;
69
+ }
70
+ if (userChoice === 'Y') {
71
+ const devIndex = commandArr.findIndex((val) => val === 'dev');
72
+ commandArr[devIndex] = 'dev-puppeteer';
73
+ }
74
+ (0, child_process_1.spawn)("npm", commandArr, {
75
+ cwd: path.join(__dirname, "../"),
76
+ env: productionEnv,
77
+ shell: true,
78
+ stdio: "inherit",
79
+ });
80
+ process.exit(0);
81
+ });
82
+ }
83
+ else {
84
+ (0, child_process_1.spawn)("npm", ['run', 'dev'], {
85
+ cwd: path.join(__dirname, "../"),
86
+ env: productionEnv,
87
+ shell: true,
88
+ stdio: "inherit",
89
+ });
90
+ }
41
91
  }
42
92
  }
43
93
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "at-builder",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "main": "bin/index.js",
5
5
  "bin": {
6
6
  "atb": "bin/index.js"
@@ -8,7 +8,8 @@
8
8
  "scripts": {
9
9
  "build": "tsc -w",
10
10
  "build-prod": "NODE_ENV=production node_modules/.bin/webpack",
11
- "dev": "node_modules/.bin/webpack -- -w & npm run puppeteer",
11
+ "dev": "node_modules/.bin/webpack -- -w",
12
+ "dev-puppeteer": "node_modules/.bin/webpack -- -w & npm run puppeteer",
12
13
  "test": "echo \"Error: no test specified\" && exit 1",
13
14
  "new-activity": "plop",
14
15
  "puppeteer": "node puppeteer.js $b"
@@ -19,41 +20,42 @@
19
20
  "url": "https://pscode.lioncloud.net/upesenga"
20
21
  },
21
22
  "license": "MIT",
22
- "devDependencies": {},
23
23
  "dependencies": {
24
- "@babel/preset-react": "^7.18.6",
25
- "@types/node": "^17.0.29",
26
- "babel-loader": "^8.2.5",
27
- "commander": "^9.4.0",
28
- "eslint": "^7.32.0",
29
- "eslint-loader": "^4.0.2",
30
- "eslint-webpack-plugin": "^3.2.0",
31
- "plop": "^3.1.1",
32
- "postcss-preset-env": "^7.7.2",
33
- "sass": "^1.53.0",
34
- "typescript": "^4.6.3",
35
- "webpack-cli": "^4.9.2",
36
24
  "@babel/eslint-parser": "^7.18.9",
37
25
  "@babel/plugin-proposal-class-properties": "^7.18.6",
38
26
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
39
27
  "@babel/plugin-transform-runtime": "^7.18.9",
40
28
  "@babel/preset-env": "^7.18.9",
29
+ "@babel/preset-react": "^7.18.6",
41
30
  "@babel/runtime": "^7.18.9",
31
+ "@types/node": "^17.0.29",
42
32
  "async": "^3.2.3",
33
+ "babel-loader": "^8.2.5",
43
34
  "babel-plugin-transform-async-to-generator": "^6.24.1",
35
+ "build": "^0.1.4",
44
36
  "chokidar": "^3.5.3",
45
37
  "cli-color": "^2.0.3",
38
+ "commander": "^9.4.0",
46
39
  "cross-env": "^7.0.3",
47
40
  "css-loader": "^6.7.1",
48
41
  "dotenv": "^16.0.0",
42
+ "eslint": "^7.32.0",
43
+ "eslint-loader": "^4.0.2",
44
+ "eslint-webpack-plugin": "^3.2.0",
45
+ "plop": "^3.1.1",
49
46
  "postcss": "^8.4.12",
50
47
  "postcss-loader": "^7.0.1",
48
+ "postcss-preset-env": "^7.7.2",
51
49
  "puppeteer": "^13.6.0",
50
+ "readline": "^1.3.0",
51
+ "sass": "^1.53.0",
52
52
  "sass-loader": "^13.0.2",
53
53
  "style-loader": "^3.3.1",
54
54
  "terser-webpack-plugin": "^5.3.3",
55
55
  "ts-loader": "^9.3.1",
56
+ "typescript": "^4.6.3",
56
57
  "webpack": "^5.72.0",
58
+ "webpack-cli": "^4.9.2",
57
59
  "wrapper-webpack-plugin": "^2.1.0"
58
60
  }
59
61
  }
package/puppeteer.js CHANGED
@@ -3,7 +3,19 @@ const puppeteer = require('puppeteer');
3
3
  const path = require('path');
4
4
  const fs = require('fs');
5
5
  const chokidar = require('chokidar');
6
- const watchConfig = "./../watch-config.json";
6
+ //const watchConfig = "./../watch-config.json";
7
+
8
+ const { executionPath } = process.env;
9
+ let watchConfig = '';
10
+ try{
11
+ watchConfig = path.join(executionPath,"watch-config.json");
12
+ }
13
+ catch(e){
14
+ throw new Error(`Error : Couldn't find watch-config.json file at location ${executionPath}`);
15
+ }
16
+
17
+
18
+ console.log("executionPath",executionPath);
7
19
 
8
20
 
9
21
  const watcher = chokidar.watch("file", {
package/src/index.ts CHANGED
@@ -4,6 +4,26 @@ import { spawn } from "child_process";
4
4
  import { getHelpInfo } from "./constants/config";
5
5
  const path = require("path");
6
6
  const fs = require("fs");
7
+ const readline = require('readline');
8
+
9
+ import * as inquirer from 'inquirer';
10
+
11
+
12
+ // inquirer
13
+ // .prompt([
14
+
15
+ // ])
16
+ // .then((answers) => {
17
+ // // Use user feedback for... whatever!!
18
+ // })
19
+ // .catch((error) => {
20
+ // if (error.isTtyError) {
21
+ // // Prompt couldn't be rendered in the current environment
22
+ // } else {
23
+ // // Something else went wrong
24
+ // }
25
+ // });
26
+
7
27
 
8
28
  try {
9
29
  fs.accessSync(path.join(process.cwd(), ".env"), fs.constants.R_OK);
@@ -11,7 +31,6 @@ try {
11
31
  throw `Error : Couldn't find .env file at location ${process.cwd()}`;
12
32
  }
13
33
 
14
-
15
34
  const commander = require("commander");
16
35
  commander
17
36
  .version("1.0.0", "-v, --version")
@@ -21,10 +40,11 @@ commander
21
40
  .parse(process.argv);
22
41
 
23
42
  const options = commander.opts();
43
+ let userChoice = '';
24
44
  var productionEnv = Object.create(process.env);
25
45
  productionEnv.executionPath = process.cwd();
26
46
 
27
-
47
+ console.log("OPTIONS COmmand", options.command)
28
48
  switch (options.command) {
29
49
  case "new": {
30
50
  spawn("npm", ["run", "new-activity"], {
@@ -37,15 +57,46 @@ switch (options.command) {
37
57
  break;
38
58
  }
39
59
  case "build": {
40
- if(options.prod) {
41
- process.env['NODE_ENV'] = 'production';
42
- }
43
- spawn("npm", ["run", "dev"], {
44
- cwd: path.join(__dirname, "../"),
45
- env: productionEnv,
46
- shell: true,
47
- stdio: "inherit",
48
- });
60
+ if (options.prod) {
61
+ process.env['NODE_ENV'] = 'production';
62
+ }
63
+
64
+ if (!options.prod) {
65
+ const rl = readline.createInterface({
66
+ input: process.stdin,
67
+ output: process.stdout
68
+ });
69
+ rl.question('Do you want open your build in a browser tab: Y/N ? ', function (ans) {
70
+ console.log(`ANSWER ${ans}`)
71
+ userChoice = ans;
72
+ rl.close();
73
+ });
74
+
75
+ rl.on('close', function () {
76
+ const commandArr = ['run', 'dev'];
77
+ if (userChoice !== 'Y' && userChoice !== 'N') {
78
+ return;
79
+ }
80
+ if (userChoice === 'Y') {
81
+ const devIndex = commandArr.findIndex((val) => val === 'dev');
82
+ commandArr[devIndex] = 'dev-puppeteer';
83
+ }
84
+ spawn("npm", commandArr, {
85
+ cwd: path.join(__dirname, "../"),
86
+ env: productionEnv,
87
+ shell: true,
88
+ stdio: "inherit",
89
+ });
90
+ process.exit(0);
91
+ });
92
+ } else {
93
+ spawn("npm", ['run', 'dev'], {
94
+ cwd: path.join(__dirname, "../"),
95
+ env: productionEnv,
96
+ shell: true,
97
+ stdio: "inherit",
98
+ });
99
+ }
49
100
  }
50
101
  }
51
102
 
@@ -64,3 +115,4 @@ if (symbols.length === 0) {
64
115
  printCommandHelp();
65
116
  process.exit(0);
66
117
  }
118
+