@makano/rew 1.2.75 → 1.2.77

Sign up to get free protection for your applications and to get access to all the features.
@@ -123,10 +123,31 @@ yargs(hideBin(process.argv))
123
123
  yargs.positional('path', {
124
124
  describe: 'Path of the project to create',
125
125
  type: 'string',
126
+ }).option('git', {
127
+ alias: 'g',
128
+ describe: `Enable Git Option`,
129
+ type: 'boolean',
130
+ }).option('civet', {
131
+ alias: 'c',
132
+ describe: `Use civet for main`,
133
+ type: 'boolean',
134
+ }).option('types', {
135
+ alias: 't',
136
+ describe: `Create @types/rew in node modules`,
137
+ type: 'boolean',
138
+ }).option('name', {
139
+ alias: 'n',
140
+ describe: `The package name`,
141
+ type: 'string'
142
+ }).option('ignore', {
143
+ alias: 'i',
144
+ describe: `Use default options`,
145
+ type: 'boolean',
146
+ default: false
126
147
  });
127
148
  },
128
149
  (argv) => {
129
- require('./utils').createProject(argv.path);
150
+ require('./utils').createProject(argv.path, argv);
130
151
  },
131
152
  )
132
153
  .command(
@@ -8,7 +8,7 @@ let last = '';
8
8
 
9
9
  const log = (module.exports.log = function (...toPrint) {
10
10
  let prefix = start ? startPrefix : middlePrefix;
11
- let returns = false;
11
+ let returns = false, nosep = false;
12
12
  if (toPrint[toPrint.length - 1] == ':end') {
13
13
  prefix = endPrefix;
14
14
  toPrint.pop();
@@ -17,13 +17,17 @@ const log = (module.exports.log = function (...toPrint) {
17
17
  returns = true;
18
18
  toPrint.pop();
19
19
  }
20
+ if (toPrint[toPrint.length - 1] == ':nosep') {
21
+ nosep = true;
22
+ toPrint.pop();
23
+ }
20
24
  if (prefix == endPrefix && start) prefix = separator;
21
25
  // if(last == endPrefix && prefix == separator) prefix = startPrefix;
22
- if (!start) console.log(last == endPrefix ? startPrefix : separator);
26
+ if (!start && !returns && !nosep) console.log(last == endPrefix ? startPrefix : separator);
23
27
  if (start) start = false;
24
28
  last = prefix;
25
29
  if (returns) return [prefix, ...toPrint].join(' ');
26
- else console.log(prefix, ...toPrint);
30
+ else if (toPrint.length) console.log(prefix, ...toPrint);
27
31
  });
28
32
 
29
33
  module.exports.logget = function (...toPrint) {
@@ -26,6 +26,7 @@ const {
26
26
  cachepath,
27
27
  localBinPath
28
28
  } = require('./helpers');
29
+ const { input } = require('../functions/stdout');
29
30
 
30
31
  module.exports = {
31
32
  conf(command, fullPath, key, value) {
@@ -77,13 +78,19 @@ module.exports = {
77
78
  }
78
79
  }
79
80
  },
80
- createProject: (ppath) => {
81
+ createProject: (ppath, argv) => {
81
82
  const projectPath = path.join(process.cwd(), ppath);
82
83
  log(''.cyan, 'Creating at'.blue, ppath.yellow);
83
- const rl = readline.createInterface({
84
- input: process.stdin,
85
- output: process.stdout,
86
- });
84
+
85
+ const b = (value, type) => type == "boolean" ? (value.toString() == 'y' || value.toString() == "yes" ? true : false) : value;
86
+
87
+ const registerInput = (name, promptText, type, argvName, defaultValue) => {
88
+ if(type == 'boolean') defaultValue = false;
89
+ let prompted = false;
90
+ project[name] = argv[argvName] ?? (argv.ignore ? defaultValue ?? b(input(promptText, prompted = log() || true), type) : b(input(promptText, prompted = log() || true), type));
91
+ log(name.grey+'?'.grey, type == 'string' ? project[name].green : (project[name] == true ? 'yes'.cyan : 'no'.yellow), prompted ? ':nosep' : '');
92
+ }
93
+
87
94
  const project = {};
88
95
  const create = () => {
89
96
  fs.mkdirSync(projectPath, { recursive: true });
@@ -97,8 +104,8 @@ module.exports = {
97
104
  execSync('cd ' + projectPath + ' && git init . && git branch -m main', { stdio: 'ignore' });
98
105
  }
99
106
  if(project.intellisense){
100
- fs.copyFileSync(path.join(__dirname, '../../../tsconfig.json'), path.join(projectPath, 'tsconfig.json'));
101
- fs.copyFileSync(path.join(__dirname, '../../../runtime.d.ts'), path.join(projectPath, 'runtime.d.ts'));
107
+ fs.mkdirSync(path.join(projectPath, 'node_modules/@types/rew'), { recursive: true });
108
+ fs.copyFileSync(path.join(__dirname, '../../../runtime.d.ts'), path.join(projectPath, 'node_modules/@types/rew/index.d.ts'));
102
109
  }
103
110
  execSync('cd ' + projectPath + ' && npm init -y', { stdio: 'ignore' });
104
111
  if(project.civet){
@@ -115,29 +122,41 @@ module.exports = {
115
122
  // }
116
123
  // });
117
124
  log('Done.'.blue.bold, ':end');
118
- rl.close();
119
125
  };
120
126
  if (!fs.existsSync(projectPath)) {
121
- rl.question(logget(' Package Name: '.blue), (pkg) => {
122
- if (pkg.trim()) {
123
- project.package = pkg.trim();
124
- rl.question(logget(' Use intellisense declarations ? (y/N): '.magenta.bold), (inteli) => {
125
- project.intellisense = inteli.toLowerCase() == 'y' || inteli.toLowerCase() == 'yes';
126
- rl.question(logget(' Use Civet For main ? (y/N): '.blue.bold), (civet) => {
127
- project.civet = civet.toLowerCase() == 'y' || civet.toLowerCase() == 'yes';
128
- rl.question(logget('󰊢 Use git ? (y/N): '.yellow.bold), (use_git) => {
129
- project.git = use_git.toLowerCase() == 'y' || use_git.toLowerCase() == 'yes';
130
- create();
131
- });
132
- });
133
- });
134
- } else {
135
- rl.close();
136
- }
137
- });
127
+
128
+ registerInput(
129
+ 'package',
130
+ logget(' Package Name: '.blue),
131
+ 'string',
132
+ 'name',
133
+ path.basename(projectPath)
134
+ )
135
+
136
+ registerInput(
137
+ 'intellisense',
138
+ logget(' Use intellisense declarations ? (y/N): '.magenta),
139
+ 'boolean',
140
+ 'types'
141
+ )
142
+
143
+ registerInput(
144
+ 'civet',
145
+ logget(' Use Civet For main ? (y/N): '.blue),
146
+ 'boolean',
147
+ 'civet'
148
+ )
149
+
150
+ registerInput(
151
+ 'git',
152
+ logget('󰊢 Use git ? (y/N): '.yellow),
153
+ 'boolean',
154
+ 'git'
155
+ )
156
+
157
+ create();
138
158
  } else {
139
159
  log(` Project ${ppath} already exists at ${projectPath}`.red.bold, ':end');
140
- rl.close();
141
160
  }
142
161
  },
143
162
  runApp(pathOrPackage, options) {
@@ -97,6 +97,7 @@ module.exports.imp = function (runPath, context) {
97
97
  if (ispkg) {
98
98
  const pkg = getPackage(filename)(context, options);
99
99
  exports = pkg._onImport ? pkg._onImport() : pkg;
100
+ if(options.useDefaultForPackages) exports = { default: exports };
100
101
  } else if (foundCache) {
101
102
  } else if (type == REW_FILE_TYPE.TYPE || type == "coffee") {
102
103
  exports = exec({});
@@ -297,7 +297,18 @@ function compileRewStuff(content, options) {
297
297
 
298
298
  if (nextLastToken?.value == 'assert') {
299
299
  result += ', ';
300
+ const assertionToken = gnextToken(nextLastToken.ti, 2, tokens);
301
+ if(assertionToken.token.type == 'OTHER' && assertionToken.token.value == '{'){
302
+ hooks.push({
303
+ index: assertionToken.token.ti,
304
+ value: ' useDefaultForPackages: true, '
305
+ })
306
+ } else {
307
+ result += 'useDefaultForPackages: true, '
308
+ }
300
309
  i += 3;
310
+ } else {
311
+ result += ", { useDefaultForPackages: true }"
301
312
  }
302
313
 
303
314
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.75",
3
+ "version": "1.2.77",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {
@@ -12,7 +12,6 @@
12
12
  "files": [
13
13
  "lib/",
14
14
  "runtime.d.ts",
15
- "jsconfig.json",
16
15
  "main.js",
17
16
  "README.md"
18
17
  ],