polylith 0.1.34 → 0.1.36
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/apps.js +0 -6
- package/bin/polylith.js +35 -15
- package/bin/utils.js +0 -1
- package/package.json +1 -1
package/bin/apps.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
apps.js
|
|
2
1
|
import path from 'node:path/posix';
|
|
3
2
|
import {readFile} from 'node:fs/promises';
|
|
4
3
|
import {ConfigApp} from '@polylith/builder';
|
|
@@ -107,7 +106,6 @@ async function getApp(spec, options) {
|
|
|
107
106
|
return app;
|
|
108
107
|
}
|
|
109
108
|
|
|
110
|
-
|
|
111
109
|
async function walkApps(name, config, options, cb) {
|
|
112
110
|
var specs = getAppSpecs(name, config, options);
|
|
113
111
|
var apps = [];
|
|
@@ -124,8 +122,6 @@ async function walkApps(name, config, options, cb) {
|
|
|
124
122
|
|
|
125
123
|
}
|
|
126
124
|
|
|
127
|
-
|
|
128
|
-
|
|
129
125
|
/**
|
|
130
126
|
* Call this method to build all the applications specified on the command line
|
|
131
127
|
*
|
|
@@ -145,7 +141,6 @@ export async function build(name, config, options, watch) {
|
|
|
145
141
|
return apps;
|
|
146
142
|
}
|
|
147
143
|
|
|
148
|
-
|
|
149
144
|
async function server(options) {
|
|
150
145
|
var server = new PolylithServer(options, options.dest);
|
|
151
146
|
await server.create(options.apps);
|
|
@@ -153,7 +148,6 @@ async function server(options) {
|
|
|
153
148
|
}
|
|
154
149
|
|
|
155
150
|
export async function watch(name, config, options) {
|
|
156
|
-
console.log('watch', name, config, options);
|
|
157
151
|
var apps = await build(name, config, options, true);
|
|
158
152
|
|
|
159
153
|
for (let app of apps) {
|
package/bin/polylith.js
CHANGED
|
@@ -73,14 +73,13 @@ function getOption(name, short) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
77
|
-
* be in the working directory.
|
|
76
|
+
* Caqll this method to read a single configuration JSON file,
|
|
78
77
|
*
|
|
79
|
-
* @
|
|
80
|
-
*
|
|
78
|
+
* @param {String} filename the path of the file to read
|
|
79
|
+
*
|
|
80
|
+
* @returns {Object} the configuration
|
|
81
81
|
*/
|
|
82
|
-
async function
|
|
83
|
-
var filename = path.join(workingDir(), 'polylith.json');
|
|
82
|
+
async function readOneConfig(filename) {
|
|
84
83
|
var exists = await fileExists(filename);
|
|
85
84
|
var config = {};
|
|
86
85
|
|
|
@@ -88,7 +87,7 @@ async function readConfig() {
|
|
|
88
87
|
try {
|
|
89
88
|
config = JSON.parse(await readFile(filename, 'utf-8'));
|
|
90
89
|
} catch (e) {
|
|
91
|
-
console.warn('unable to load polylith configuration file');
|
|
90
|
+
console.warn('unable to load polylith configuration file ', filename);
|
|
92
91
|
console.warn(e.message);
|
|
93
92
|
}
|
|
94
93
|
}
|
|
@@ -96,6 +95,27 @@ async function readConfig() {
|
|
|
96
95
|
return config;
|
|
97
96
|
}
|
|
98
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Call this method to read the polylith configuration file and the environment
|
|
100
|
+
* specific configuration file. This is assumed to be in the working directory.
|
|
101
|
+
*
|
|
102
|
+
* @returns {Object} the json parsed object from the config file, or the default
|
|
103
|
+
* options if the file does not exist
|
|
104
|
+
*/
|
|
105
|
+
async function readConfig() {
|
|
106
|
+
var envExt = process.env.NODE_ENV ? '.' + process.env.NODE_ENV : false;
|
|
107
|
+
var filename = path.join(workingDir(), 'polylith.json');
|
|
108
|
+
var envFilename = path.join(workingDir(), `polylith${envExt}.json`)
|
|
109
|
+
var config = await readOneConfig(filename);
|
|
110
|
+
var envConfig = {};
|
|
111
|
+
|
|
112
|
+
if (envExt) {
|
|
113
|
+
envConfig = await readOneConfig(envFilename);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return {...config, ...envConfig}
|
|
117
|
+
}
|
|
118
|
+
|
|
99
119
|
/**
|
|
100
120
|
* Call this method to sort the top level keys of the given object.
|
|
101
121
|
*
|
|
@@ -136,7 +156,7 @@ async function writeConfig(config) {
|
|
|
136
156
|
* Call this method to get the current options. Order of precedence is default,
|
|
137
157
|
* polylith.json and command line
|
|
138
158
|
*/
|
|
139
|
-
async function
|
|
159
|
+
async function getOptions() {
|
|
140
160
|
var config = await readConfig();
|
|
141
161
|
|
|
142
162
|
clOptions = {...clOptions, ...config};
|
|
@@ -219,19 +239,19 @@ function camelCase(name) {
|
|
|
219
239
|
}
|
|
220
240
|
|
|
221
241
|
/**
|
|
222
|
-
* Call this method to normalize the name so that
|
|
223
|
-
* case and separated by '_'. The name is
|
|
224
|
-
*
|
|
242
|
+
* Call this method to normalize the name so that it is in snake case: each
|
|
243
|
+
* individual part is lower case and separated by '_'. The passed name is
|
|
244
|
+
* assumed to be either separated with one of [' ', '-', '_'] or is in camel
|
|
245
|
+
* case or pascal case.
|
|
225
246
|
*
|
|
226
247
|
* @param {String} name the name to normalize
|
|
227
248
|
*
|
|
228
|
-
* @returns {String} the normalized string which will be
|
|
229
|
-
part separated with '_';
|
|
249
|
+
* @returns {String} the normalized string which will be in snake case;
|
|
230
250
|
*/
|
|
231
251
|
function normalizeCase(name) {
|
|
232
252
|
if (!name) return;
|
|
233
253
|
|
|
234
|
-
//
|
|
254
|
+
// start with pascal case, because we will break it into pieces based on
|
|
235
255
|
// each part starting with an upercase letter.
|
|
236
256
|
name = pascalCase(name);
|
|
237
257
|
|
|
@@ -374,7 +394,7 @@ function checkLocalPolylith() {
|
|
|
374
394
|
* Call this function to execure the command from the command line
|
|
375
395
|
*/
|
|
376
396
|
async function run() {
|
|
377
|
-
await
|
|
397
|
+
await getOptions();
|
|
378
398
|
var config = await readConfig();
|
|
379
399
|
|
|
380
400
|
if (!verifyParams() || argv.help || argv.h) {
|
package/bin/utils.js
CHANGED