lincd-cli 0.2.47 → 0.2.48

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