lincd-cli 0.2.42 → 0.2.43

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.
@@ -1,244 +1,313 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const config_webpack_1 = require("./config-webpack");
4
- const utils_1 = require("./utils");
1
+ 'use strict';
2
+ Object.defineProperty(exports, '__esModule', {value: true});
3
+ const config_webpack_1 = require('./config-webpack');
4
+ const utils_1 = require('./utils');
5
5
  const fs = require('fs');
6
6
  const chalk = require('chalk');
7
7
  const path = require('path');
8
+
8
9
  function generateGruntConfig(moduleName, config = {}) {
9
- return function (grunt) {
10
- setupGrunt(grunt, moduleName, config);
11
- };
10
+ return function (grunt) {
11
+ setupGrunt(grunt, moduleName, config);
12
+ };
12
13
  }
14
+
13
15
  exports.default = generateGruntConfig;
16
+
14
17
  function setupGrunt(grunt, moduleName, config) {
15
- var buildServer = !config.environment || config.environment == 'nodejs' || config.environment == 'polymorphic';
16
- var buildFrontend = !config.environment || config.environment == 'browser' || config.environment == 'polymorphic';
17
- //when not specified and we ARe building frontend OR we are compiling the server for es5.. or if simply specified, then es5 is targeted
18
- var targetES5 = (!config.target && (buildFrontend || config.es5Server)) || config.target == 'es5';
19
- var targetES6 = !config.target || config.target == 'es6';
20
- var targets = [];
21
- if (targetES5)
22
- targets.push('es5');
23
- if (targetES6)
24
- targets.push('es6');
25
- var targetLog = 'building ' + targets.join(', ');
26
- if (buildServer && !buildFrontend) {
27
- (0, utils_1.log)(targetLog + ' lib only');
18
+ var buildServer = !config.environment || config.environment == 'nodejs' || config.environment == 'polymorphic';
19
+ var buildFrontend = !config.environment || config.environment == 'browser' || config.environment == 'polymorphic';
20
+ //when not specified and we ARe building frontend OR we are compiling the server for es5.. or if simply specified, then es5 is targeted
21
+ var targetES5 = (!config.target && (buildFrontend || config.es5Server)) || config.target == 'es5';
22
+ var targetES6 = !config.target || config.target == 'es6';
23
+ var targets = [];
24
+ if (targetES5) targets.push('es5');
25
+ if (targetES6) targets.push('es6');
26
+ var targetLog = 'building ' + targets.join(', ');
27
+ if (buildServer && !buildFrontend) {
28
+ (0, utils_1.log)(targetLog + ' lib only');
29
+ } else if (!buildServer && buildFrontend) {
30
+ (0, utils_1.log)(targetLog + ' dist bundles only');
31
+ } else if (buildServer && buildFrontend) {
32
+ if (config.es5Server) {
33
+ (0, utils_1.log)(targetLog + ' lib files & dist bundles');
34
+ } else {
35
+ (0, utils_1.log)(targetLog + ' dist bundles and es6 lib files');
28
36
  }
29
- else if (!buildServer && buildFrontend) {
30
- (0, utils_1.log)(targetLog + ' dist bundles only');
31
- }
32
- else if (buildServer && buildFrontend) {
33
- if (config.es5Server) {
34
- (0, utils_1.log)(targetLog + ' lib files & dist bundles');
35
- }
36
- else {
37
- (0, utils_1.log)(targetLog + ' dist bundles and es6 lib files');
38
- }
39
- }
40
- else {
41
- (0, utils_1.log)('invalid configuration combination');
42
- }
43
- require('load-grunt-tasks')(grunt);
44
- //defaults
45
- grunt.registerTask('default', ['prepare-build', 'concurrent:dev']);
46
- grunt.registerTask('dev', targetES6 ? ['prepare-build', 'dev-es6'] : ['prepare-build', 'dev-es5']);
47
- grunt.registerTask('build', targets.map((target) => 'build-' + target));
48
- if (buildFrontend) {
49
- grunt.registerTask('build-frontend', ['prepare-build', ...targets.map((target) => 'webpack:build-' + target)]);
50
- }
51
- grunt.registerTask('build-production', (0, utils_1.flatten)([
52
- 'clean:lib',
53
- 'prepare-build',
54
- buildFrontend ? targets.map((target) => 'webpack:prod-' + target) : null,
55
- buildServer ? ['exec:build-lib', 'copy:lib'] : null,
56
- ]));
57
- let prepareBuild = ['postcss:cssjson'];
58
- if (config.beforeBuildCommand) {
59
- prepareBuild.push('exec:beforeBuildCommand');
60
- }
61
- //specific tasks
62
- grunt.registerTask('prepare-build', prepareBuild);
63
- grunt.registerTask('dev-es6-production', ['prepare-build', 'concurrent:dev-prod']);
64
- grunt.registerTask('dev-es6', ['prepare-build', 'concurrent:dev']);
65
- grunt.registerTask('dev-es5', ['prepare-build', 'concurrent:dev-es5']);
66
- //build-es5 is by default just the frontend because the server is es6
67
- //however some specific modules (like @dacore/module) require the typescript compiler ('build-lib') to run for es5
68
- //so that core-es5 or browser-core-es5 can internalise its files
69
- //this can by triggered with es5Server
70
- grunt.registerTask('build-es5', (0, utils_1.flatten)([
71
- 'postcss',
72
- buildFrontend ? 'webpack:build-es5' : null,
73
- config.es5Server ? ['exec:build-lib-es5', 'copy:lib'] : null,
74
- ]));
75
- grunt.registerTask('build-es6', (0, utils_1.flatten)([
76
- 'prepare-build',
77
- buildFrontend ? 'webpack:build-es6' : null,
78
- buildServer ? ['clean:lib', 'exec:build-lib', 'copy:lib', 'exec:depcheck'] : null,
79
- // 'exec:shapes',
80
- ]));
81
- grunt.registerTask('build-lib', ['prepare-build', 'exec:build-lib', 'copy:lib']);
82
- grunt.registerTask('build-production-es5', [
83
- 'prepare-build',
84
- 'webpack:prod-es5',
85
- // 'exec:shapes',
86
- ]);
87
- grunt.registerTask('build-production-es6', [
88
- 'prepare-build',
89
- 'webpack:prod-es6',
90
- // 'exec:shapes',
91
- ]);
92
- // log('setting grunt config');
93
- grunt.initConfig({
94
- exec: {
95
- 'build-lib': 'yarn exec tsc --pretty',
96
- 'build-lib-es5': 'yarn exec tsc --pretty -p tsconfig-es5.json',
97
- beforeBuildCommand: config.beforeBuildCommand,
98
- 'server-dev': 'tsc -w',
99
- depcheck: 'yarn lincd depcheck',
100
- test: 'tsc -w',
101
- // shapes: 'lincd shapes',
102
- 'css-declarations': 'tcm -p **/*.scss',
103
- 'postcss-modules': 'yarn postcss --use postcss-import postcss-nested postcss-modules -o build/draft.css -i scss/*',
104
- },
105
- copy: {
106
- lib: {
107
- files: [
108
- // copy json files in src over to lib
109
- {
110
- expand: true,
111
- src: ['**/*.json', '**/*.d.ts', '**/*.scss', '**/*.css'],
112
- dest: 'lib/',
113
- cwd: 'src/',
114
- filter: 'isFile',
115
- },
116
- ],
117
- },
37
+ } else {
38
+ (0, utils_1.log)('invalid configuration combination');
39
+ }
40
+ require('load-grunt-tasks')(grunt);
41
+ //defaults
42
+ grunt.registerTask('default', ['prepare-build', 'concurrent:dev']);
43
+ grunt.registerTask('dev', targetES6 ? ['prepare-build', 'dev-es6'] : ['prepare-build', 'dev-es5']);
44
+ grunt.registerTask(
45
+ 'build',
46
+ targets.map((target) => 'build-' + target),
47
+ );
48
+ if (buildFrontend) {
49
+ grunt.registerTask('build-frontend', ['prepare-build', ...targets.map((target) => 'webpack:build-' + target)]);
50
+ }
51
+ grunt.registerTask(
52
+ 'build-production',
53
+ (0, utils_1.flatten)([
54
+ 'clean:lib',
55
+ 'prepare-build',
56
+ buildFrontend ? targets.map((target) => 'webpack:prod-' + target) : null,
57
+ buildServer ? ['exec:build-lib', 'copy:lib'] : null,
58
+ ]),
59
+ );
60
+ let prepareBuild = ['postcss:cssjson'];
61
+ if (config.beforeBuildCommand) {
62
+ prepareBuild.push('exec:beforeBuildCommand');
63
+ }
64
+ //specific tasks
65
+ grunt.registerTask('prepare-build', prepareBuild);
66
+ grunt.registerTask('dev-es6-production', ['prepare-build', 'concurrent:dev-prod']);
67
+ grunt.registerTask('dev-es6', ['prepare-build', 'concurrent:dev']);
68
+ grunt.registerTask('dev-es5', ['prepare-build', 'concurrent:dev-es5']);
69
+ //build-es5 is by default just the frontend because the server is es6
70
+ //however some specific modules (like @dacore/module) require the typescript compiler ('build-lib') to run for es5
71
+ //so that core-es5 or browser-core-es5 can internalise its files
72
+ //this can by triggered with es5Server
73
+ grunt.registerTask(
74
+ 'build-es5',
75
+ (0, utils_1.flatten)([
76
+ 'postcss',
77
+ buildFrontend ? 'webpack:build-es5' : null,
78
+ config.es5Server ? ['exec:build-lib-es5', 'copy:lib'] : null,
79
+ ]),
80
+ );
81
+ grunt.registerTask(
82
+ 'build-es6',
83
+ (0, utils_1.flatten)([
84
+ 'prepare-build',
85
+ buildFrontend ? 'webpack:build-es6' : null,
86
+ buildServer ? ['clean:lib', 'exec:build-lib', 'copy:lib', 'exec:depcheck'] : null,
87
+ // 'exec:shapes',
88
+ ]),
89
+ );
90
+ grunt.registerTask('build-lib', ['prepare-build', 'exec:build-lib', 'copy:lib']);
91
+ grunt.registerTask('build-production-es5', [
92
+ 'prepare-build',
93
+ 'webpack:prod-es5',
94
+ // 'exec:shapes',
95
+ ]);
96
+ grunt.registerTask('build-production-es6', [
97
+ 'prepare-build',
98
+ 'webpack:prod-es6',
99
+ // 'exec:shapes',
100
+ ]);
101
+ // log('setting grunt config');
102
+ grunt.initConfig({
103
+ exec: {
104
+ 'build-lib': 'yarn exec tsc --pretty',
105
+ 'build-lib-es5': 'yarn exec tsc --pretty -p tsconfig-es5.json',
106
+ beforeBuildCommand: config.beforeBuildCommand,
107
+ 'server-dev': 'tsc -w',
108
+ depcheck: 'yarn lincd depcheck',
109
+ test: 'tsc -w',
110
+ // shapes: 'lincd shapes',
111
+ 'css-declarations': 'tcm -p **/*.scss',
112
+ 'postcss-modules':
113
+ 'yarn postcss --use postcss-import postcss-nested postcss-modules -o build/draft.css -i scss/*',
114
+ },
115
+ copy: {
116
+ lib: {
117
+ files: [
118
+ // copy json files in src over to lib
119
+ {
120
+ expand: true,
121
+ src: ['**/*.json', '**/*.d.ts', '**/*.scss', '**/*.css'],
122
+ dest: 'lib/',
123
+ cwd: 'src/',
124
+ filter: 'isFile',
125
+ },
126
+ ],
127
+ },
128
+ },
129
+ postcss: {
130
+ options: {
131
+ map: true,
132
+ processors: [require('postcss-modules')({generateScopedName: utils_1.generateScopedName})],
133
+ syntax: require('postcss-scss'),
134
+ writeDest: false,
135
+ },
136
+ cssjson: {
137
+ src: 'src/**/*.scss',
138
+ },
139
+ },
140
+ clean: {
141
+ lib: ['lib/'],
142
+ },
143
+ concurrent: {
144
+ dev: (0, utils_1.flatten)([
145
+ buildFrontend ? 'webpack:dev' : null,
146
+ buildServer ? 'exec:server-dev' : null,
147
+ // buildServer ? 'watch:css-module-transforms' : null,
148
+ // 'exec:css-declarations-watch'
149
+ ]),
150
+ 'dev-prod': (0, utils_1.flatten)([
151
+ buildFrontend ? 'webpack:dev-prod' : null,
152
+ buildServer ? 'exec:server-dev' : null,
153
+ // buildServer ? 'watch:css-module-transforms' : null,
154
+ // 'exec:css-declarations-watch'
155
+ ]),
156
+ 'dev-es5': (0, utils_1.flatten)([
157
+ buildFrontend ? 'webpack:dev-es5' : null,
158
+ buildServer ? 'exec:server-dev' : null,
159
+ // buildServer ? 'watch:css-module-transforms' : null,
160
+ // 'exec:css-declarations-watch'
161
+ ]),
162
+ options: {
163
+ logConcurrentOutput: true,
164
+ logTaskName: 3,
165
+ logBlacklist: [],
166
+ },
167
+ },
168
+ webpack: {
169
+ options: {
170
+ stats: {
171
+ chunks: false,
172
+ version: false,
173
+ // warningsFilter: (warning) => {
174
+ // return warning.indexOf('There are multiple modules') !== -1;
175
+ // },
118
176
  },
119
- postcss: {
120
- options: {
121
- map: true,
122
- processors: [require('postcss-modules')({ generateScopedName: utils_1.generateScopedName })],
123
- syntax: require('postcss-scss'),
124
- writeDest: false,
125
- },
126
- cssjson: {
127
- src: 'src/**/*.scss',
128
- },
129
- },
130
- clean: {
131
- lib: ['lib/'],
132
- },
133
- concurrent: {
134
- dev: (0, utils_1.flatten)([
135
- buildFrontend ? 'webpack:dev' : null,
136
- buildServer ? 'exec:server-dev' : null,
137
- // buildServer ? 'watch:css-module-transforms' : null,
138
- // 'exec:css-declarations-watch'
139
- ]),
140
- 'dev-prod': (0, utils_1.flatten)([
141
- buildFrontend ? 'webpack:dev-prod' : null,
142
- buildServer ? 'exec:server-dev' : null,
143
- // buildServer ? 'watch:css-module-transforms' : null,
144
- // 'exec:css-declarations-watch'
145
- ]),
146
- 'dev-es5': (0, utils_1.flatten)([
147
- buildFrontend ? 'webpack:dev-es5' : null,
148
- buildServer ? 'exec:server-dev' : null,
149
- // buildServer ? 'watch:css-module-transforms' : null,
150
- // 'exec:css-declarations-watch'
151
- ]),
152
- options: {
153
- logConcurrentOutput: true,
154
- logTaskName: 3,
155
- logBlacklist: [],
156
- },
157
- },
158
- webpack: {
159
- options: {
160
- stats: {
161
- chunks: false,
162
- version: false,
163
- // warningsFilter: (warning) => {
164
- // return warning.indexOf('There are multiple modules') !== -1;
165
- // },
166
- },
167
- },
168
- dev: (0, config_webpack_1.generateWebpackConfig)('dev', moduleName, Object.assign({
169
- target: 'es6',
170
- watch: true,
171
- }, config, config.es6, config.dev)),
172
- 'dev-prod': (0, config_webpack_1.generateWebpackConfig)('dev', moduleName, Object.assign({
173
- target: 'es6',
174
- watch: true,
175
- productionMode: true,
176
- }, config, config.es6, config.prod)),
177
- 'dev-es5': (0, config_webpack_1.generateWebpackConfig)('dev-es5', moduleName, Object.assign({
178
- target: 'es5',
179
- watch: true,
180
- }, config, config.es5, config.dev)),
181
- 'build-es6': (0, config_webpack_1.generateWebpackConfig)('build-es6', moduleName, Object.assign({
182
- target: 'es6',
183
- watch: false,
184
- }, config, config.es6, config.dev)),
185
- 'build-es5': (0, config_webpack_1.generateWebpackConfig)('build-es5', moduleName, Object.assign({
186
- target: 'es5',
187
- watch: false,
188
- }, config, config.es5, config.dev)),
189
- 'prod-es5': (0, config_webpack_1.generateWebpackConfig)('prod-es5', moduleName, Object.assign({
190
- target: 'es5',
191
- watch: false,
192
- productionMode: true,
193
- }, config, config.es5, config.prod)),
194
- 'prod-es6': (0, config_webpack_1.generateWebpackConfig)('prod-es6', moduleName, Object.assign({
195
- target: 'es6',
196
- watch: false,
197
- productionMode: true,
198
- }, config, config.es6, config.prod)),
199
- },
200
- });
201
- //load the npm grunt task modules
202
- [
203
- 'grunt-webpack',
204
- 'grunt-exec',
205
- 'grunt-concurrent',
206
- 'grunt-contrib-clean',
207
- 'grunt-contrib-copy',
208
- '@lodder/grunt-postcss',
209
- ].forEach((taskName) => {
210
- (0, utils_1.debug)(config, 'loading grunt task ' + taskName);
211
- let localPath = path.resolve(__dirname, '..', 'node_modules', taskName, 'tasks');
212
- let localPath2 = path.resolve(__dirname, '..', '..', 'node_modules', taskName, 'tasks');
213
- let workspacePath = path.resolve(__dirname, '..', '..', '..', 'node_modules', taskName, 'tasks');
214
- let nestedWorkspacePath = path.resolve(__dirname, '..', '..', '..', '..', 'node_modules', taskName, 'tasks');
215
- if (fs.existsSync(localPath)) {
216
- // grunt.loadNpmTasks(taskName);
217
- (0, utils_1.debug)('Loading from ' + localPath);
218
- grunt.task.loadTasks(localPath);
219
- }
220
- else if (fs.existsSync(localPath2)) {
221
- // grunt.loadNpmTasks(taskName);
222
- (0, utils_1.debug)('Loading from ' + localPath2);
223
- grunt.task.loadTasks(localPath2);
224
- }
225
- else if (fs.existsSync(workspacePath)) {
226
- //windows, so it seems
227
- (0, utils_1.debug)('Loading from ' + workspacePath);
228
- grunt.task.loadTasks(workspacePath);
229
- }
230
- else if (fs.existsSync(nestedWorkspacePath)) {
231
- //mac / linux
232
- (0, utils_1.debug)('Loading from ' + nestedWorkspacePath);
233
- grunt.task.loadTasks(nestedWorkspacePath);
234
- }
235
- else {
236
- (0, utils_1.warn)(`Could not load grunt task module ${taskName}
177
+ },
178
+ dev: (0, config_webpack_1.generateWebpackConfig)(
179
+ 'dev',
180
+ moduleName,
181
+ Object.assign(
182
+ {
183
+ target: 'es6',
184
+ watch: true,
185
+ },
186
+ config,
187
+ config.es6,
188
+ config.dev,
189
+ ),
190
+ ),
191
+ 'dev-prod': (0, config_webpack_1.generateWebpackConfig)(
192
+ 'dev',
193
+ moduleName,
194
+ Object.assign(
195
+ {
196
+ target: 'es6',
197
+ watch: true,
198
+ productionMode: true,
199
+ },
200
+ config,
201
+ config.es6,
202
+ config.prod,
203
+ ),
204
+ ),
205
+ 'dev-es5': (0, config_webpack_1.generateWebpackConfig)(
206
+ 'dev-es5',
207
+ moduleName,
208
+ Object.assign(
209
+ {
210
+ target: 'es5',
211
+ watch: true,
212
+ },
213
+ config,
214
+ config.es5,
215
+ config.dev,
216
+ ),
217
+ ),
218
+ 'build-es6': (0, config_webpack_1.generateWebpackConfig)(
219
+ 'build-es6',
220
+ moduleName,
221
+ Object.assign(
222
+ {
223
+ target: 'es6',
224
+ watch: false,
225
+ },
226
+ config,
227
+ config.es6,
228
+ config.dev,
229
+ ),
230
+ ),
231
+ 'build-es5': (0, config_webpack_1.generateWebpackConfig)(
232
+ 'build-es5',
233
+ moduleName,
234
+ Object.assign(
235
+ {
236
+ target: 'es5',
237
+ watch: false,
238
+ },
239
+ config,
240
+ config.es5,
241
+ config.dev,
242
+ ),
243
+ ),
244
+ 'prod-es5': (0, config_webpack_1.generateWebpackConfig)(
245
+ 'prod-es5',
246
+ moduleName,
247
+ Object.assign(
248
+ {
249
+ target: 'es5',
250
+ watch: false,
251
+ productionMode: true,
252
+ },
253
+ config,
254
+ config.es5,
255
+ config.prod,
256
+ ),
257
+ ),
258
+ 'prod-es6': (0, config_webpack_1.generateWebpackConfig)(
259
+ 'prod-es6',
260
+ moduleName,
261
+ Object.assign(
262
+ {
263
+ target: 'es6',
264
+ watch: false,
265
+ productionMode: true,
266
+ },
267
+ config,
268
+ config.es6,
269
+ config.prod,
270
+ ),
271
+ ),
272
+ },
273
+ });
274
+ //load the npm grunt task modules
275
+ [
276
+ 'grunt-webpack',
277
+ 'grunt-exec',
278
+ 'grunt-concurrent',
279
+ 'grunt-contrib-clean',
280
+ 'grunt-contrib-copy',
281
+ '@lodder/grunt-postcss',
282
+ ].forEach((taskName) => {
283
+ (0, utils_1.debug)(config, 'loading grunt task ' + taskName);
284
+ let localPath = path.resolve(__dirname, '..', 'node_modules', taskName, 'tasks');
285
+ let localPath2 = path.resolve(__dirname, '..', '..', 'node_modules', taskName, 'tasks');
286
+ let workspacePath = path.resolve(__dirname, '..', '..', '..', 'node_modules', taskName, 'tasks');
287
+ let nestedWorkspacePath = path.resolve(__dirname, '..', '..', '..', '..', 'node_modules', taskName, 'tasks');
288
+ if (fs.existsSync(localPath)) {
289
+ // grunt.loadNpmTasks(taskName);
290
+ (0, utils_1.debug)('Loading from ' + localPath);
291
+ grunt.task.loadTasks(localPath);
292
+ } else if (fs.existsSync(localPath2)) {
293
+ // grunt.loadNpmTasks(taskName);
294
+ (0, utils_1.debug)('Loading from ' + localPath2);
295
+ grunt.task.loadTasks(localPath2);
296
+ } else if (fs.existsSync(workspacePath)) {
297
+ //windows, so it seems
298
+ (0, utils_1.debug)('Loading from ' + workspacePath);
299
+ grunt.task.loadTasks(workspacePath);
300
+ } else if (fs.existsSync(nestedWorkspacePath)) {
301
+ //mac / linux
302
+ (0, utils_1.debug)('Loading from ' + nestedWorkspacePath);
303
+ grunt.task.loadTasks(nestedWorkspacePath);
304
+ } else {
305
+ (0, utils_1.warn)(`Could not load grunt task module ${taskName}
237
306
  Could not find task at any of these paths:
238
307
  ${localPath}
239
308
  ${localPath2}
240
309
  ${workspacePath}
241
310
  ${nestedWorkspacePath}`);
242
- }
243
- });
311
+ }
312
+ });
244
313
  }