Skip to content

Commit

Permalink
chore(ui-grid): revert build tasks to rely on grunt
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelo-portugal authored and mportuga committed Jan 23, 2023
1 parent 261012b commit 19475ea
Show file tree
Hide file tree
Showing 24 changed files with 1,153 additions and 49 deletions.
11 changes: 6 additions & 5 deletions grunt/aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ module.exports = function (grunt, options) {
// register before and after test tasks so we don't have to change cli
// options on the CI server
'before-test': [
'clean', 'shell:lint', 'ngtemplates'
],
'clean', 'shell:lint', 'ngtemplates', 'less', 'copy:font_dist','copy:packages_dist'
], // Have to run less so CSS files are present
'after-test': ['build'],
'default': ['before-test', 'test:single', 'after-test'],

// Build with no testing
'build': [
'shell:build', 'uidocs-generator',
'ngtemplates', 'concat', 'uglify', 'less', 'uidocs-generator', 'copy:font_dist', 'copy:packages_dist',
'copy:site', 'copy:less_customizer',
],
'build:less_dist': ['copy:less_dist', 'replace:less_dist'],

// Auto-test tasks for development
'autotest:unit': ['karmangular:start'],
Expand Down Expand Up @@ -53,10 +54,10 @@ module.exports = function (grunt, options) {
var currentTag = semver.clean( util.getCurrentTag() );

if (currentTag) {
baseTasks['release'] = ['cut-release', 'gh-pages:ui-grid-site', 'update-bower-json', 'gh-pages:bower', 'npm-publish'];
baseTasks['release'] = ['clean', 'ngtemplates', 'build', 'build:less_dist', 'cut-release', 'gh-pages:ui-grid-site', 'update-bower-json', 'gh-pages:bower', 'npm-publish'];
}
else {
baseTasks['release'] = ['cut-release'];
baseTasks['release'] = ['clean', 'ngtemplates', 'build', 'build:less_dist', 'cut-release'];
}

return baseTasks;
Expand Down
3 changes: 2 additions & 1 deletion grunt/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ module.exports =
// Clean the temp directory
['.tmp', '<%= dist %>', 'docs', 'coverage',
'packages/*/.npmignore', 'packages/*/LICENSE.md',
'packages/*/css', 'packages/*/dist', 'packages/*/js', 'packages/*/index.js']
'packages/*/css', 'packages/*/js', 'packages/*/*.js',
'packages/*/webpack.config.js']
;
48 changes: 48 additions & 0 deletions grunt/concat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const fs = require('fs');
const path = require('path');

const getDirectories = p => fs.readdirSync(p).filter(f => fs.statSync(path.join(p, f)).isDirectory());
const getLanguages = p => fs.readdirSync(p).filter(f => fs.statSync(path.join(p, f)).isFile());
const getTemplateDirectories = p => fs.readdirSync(p)
.filter(f => fs.statSync(path.join(p, f)).isDirectory() && fs.existsSync(path.join(p, f, 'src/templates')));
const templateDirectories = getTemplateDirectories('packages/');

function getFiles() {
const files = {
'<%= dist %>/release/<%= pkg.name %>.js': ['packages/core/src/js/bootstrap.js', 'packages/*/src/js/**/*.js', '.tmp/template.js'],
'packages/core/js/<%= pkg.name %>.core.js': ['src/js/core/bootstrap.js', 'packages/core/src/js/**/*.js', '.tmp/template-core.js']
};
const packages = getDirectories('packages/');

packages.forEach((feat) => {
if (feat === 'i18n') {
const languages = getLanguages('packages/i18n/src/js/');

files['packages/i18n/js/<%= pkg.name %>.language.all.js'] = languages.map((lang) => `packages/i18n/src/js/${lang}`);

languages.forEach((lang) => {
files[`packages/i18n/js/<%= pkg.name %>.language.${lang}`] = [`packages/i18n/src/js/${lang}`];
});
} else if (feat !== 'core') {
let src = [`packages/${feat}/src/js/**/*.js`];

if (templateDirectories.includes(feat)) {
src.push(`.tmp/template-${feat}.js`);
}

files[`packages/${feat}/js/<%= pkg.name %>.${feat}.js`] = src;
}
});

return files;
}

module.exports = {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
files: getFiles()
}
};
10 changes: 5 additions & 5 deletions grunt/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = function ( grunt ) {

packages.forEach(function(feat) {
let featModuleName = '.' + _.camelCase(feat);
let featMainPath = `./dist/${package.name}.${feat}`;
let featMainPath = `./js/${package.name}.${feat}`;

switch(feat) {
case 'cellnav':
Expand Down Expand Up @@ -185,25 +185,25 @@ module.exports = function ( grunt ) {
expand: true,
flatten: true,
cwd: 'packages',
src: '*/dist/*.js',
src: ['*/js/*.js', '!**/index.js'],
dest: '<%= dist %>/release',
filter: function(filepath) {
return !filepath.includes('packages/i18n')
return !filepath.includes('packages/i18n')
}
},
{
expand: true,
flatten: true,
cwd: 'packages',
src: '*/i18n/dist/*.js',
src: ['*/i18n/js/*.js', '!**/index.js'],
dest: '<%= dist %>/release/i18n',
filter: 'isFile'
},
{
expand: true,
flatten: true,
cwd: 'packages',
src: '*/dist/*.css',
src: '*/css/*.css',
dest: '<%= dist %>/release/css',
filter: 'isFile'
}
Expand Down
74 changes: 74 additions & 0 deletions grunt/less.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const fs = require('fs');
const path = require('path');

const getDirectories = p => fs.readdirSync(p)
.filter(f => fs.statSync(path.join(p, f)).isDirectory() && fs.existsSync(path.join(p, f, 'less')));

function filterCoreLessFiles(filepath) {
return filepath === 'packages/core/less/main.less' || !filepath.includes('packages/core/less/');
}

function getFiles(compress) {
const suffix = compress ? 'min.css' : 'css';
const files = [
{
src: ['packages/core/less/main.less', 'packages/*/less/**/*.less', '.tmp/font/ui-grid-codes.css'],
dest: `dist/release/<%= pkg.name %>.${suffix}`,
filter: filterCoreLessFiles
}
];
const packages = getDirectories('packages/');

packages.forEach((feat) => {
if (feat !== 'core') {
files.push({
src: `packages/${feat}/less/*.less`,
dest: `packages/${feat}/css/<%= pkg.name %>.${feat}.${suffix}`,
filter: filterCoreLessFiles
});
}
});

return files;
}

module.exports = {
core: {
options: {
banner: '<%= banner %>',
modifyVars: {
'font-path': '../fonts/'
}
},
files: [{
src: 'packages/core/less/main.less',
dest: 'packages/core/css/<%= pkg.name %>.core.css'
}]
},
core_min: {
options: {
banner: '<%= banner %>',
modifyVars: {
'font-path': '../fonts/'
},
compress: true
},
files: [{
src: 'packages/core/less/main.less',
dest: 'packages/core/css/<%= pkg.name %>.core.min.css'
}]
},
dist: {
options: {
banner: '<%= banner %>'
},
files: getFiles()
},
min: {
options: {
banner: '<%= banner %>',
compress: true
},
files: getFiles(true)
}
};
19 changes: 19 additions & 0 deletions grunt/replace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
less_dist: {
options: {
patterns: [
{
match: /..\/..\/core\/less\//g,
replace: './'
}
]
},
files: [
{
expand: true,
src: '<%= dist %>/release/less/*.less',
dest: './'
}
]
}
};
3 changes: 0 additions & 3 deletions grunt/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ module.exports = function() {
async: true
}
},
build: {
command: 'npm run build'
},
lint: {
command: 'npm run lint'
},
Expand Down
21 changes: 21 additions & 0 deletions grunt/uglify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const concat = require('./concat');

function getFiles() {
const files = {};
const sources = Object.keys(concat.dist.files);

sources.forEach((srcFile) => {
files[srcFile.replace('.js', '.min.js')] = srcFile;
});

return files;
}

module.exports = {
options: {
banner: '<%= banner %>'
},
concat: {
files: getFiles()
}
};
4 changes: 2 additions & 2 deletions grunt/uidocs-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ module.exports = {
versions: {
stable: [
{ src: '/release/<%= pkg.name %>.js', type: 'script' },
{ src: '/release/css/<%= pkg.name %>.css', type: 'css' }
{ src: '/release/<%= pkg.name %>.css', type: 'css' }
],
unstable: [
{ src: '/release/<%= pkg.name %>-unstable.js', type: 'script' },
{ src: '/release/css/<%= pkg.name %>-unstable.css', type: 'css' }
{ src: '/release/<%= pkg.name %>-unstable.css', type: 'css' }
]
}
},
Expand Down
8 changes: 4 additions & 4 deletions grunt/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ module.exports = function( grunt, options ){

gruntfile: {
files: ['packages/*/src/**/*.js', 'packages/*/test/**/*.spec.js', 'test/**/*.spec.js', 'grunt/*.js'],
tasks: ['shell:lint', 'shell:build', 'uidocs-generator']
tasks: ['shell:lint', 'uidocs-generator']
},

ngtemplates: {
// files: ['packages/*/src/templates/**/*.html'],
files: '<%= ngtemplates.uigrid.src %>',
tasks: ['ngtemplates', 'shell:build']
tasks: ['ngtemplates']
},

rebuild: {
files: util.testFiles.unit,
tasks: ['shell:lint', 'karmangular:run', 'shell:build', 'uidocs-generator'],
tasks: ['shell:lint', 'karmangular:run', 'concat', 'uglify', 'uidocs-generator'],
},

protractor: {
Expand All @@ -27,7 +27,7 @@ module.exports = function( grunt, options ){

less: {
files: 'src/**/*.less',
tasks: ['shell:less', 'uidocs-generator', 'concat:customizer_less']
tasks: ['less', 'uidocs-generator', 'concat:customizer_less']
},

docs: {
Expand Down
8 changes: 4 additions & 4 deletions lib/grunt/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ var grunt = require('grunt');
var semver = require('semver');
var shell = require('shelljs');

// Get the list of angular files (angular.js, angular-mocks.js, etc)
var cachedAngularFiles = grunt.file.readJSON('lib/test/angular/files.json');

var util = module.exports = {

testDependencies: {
unit: ['bower_components/jquery/jquery.min.js', 'lib/test/jquery.simulate.js','lib/test/classList.polyFill.js', 'dist/release/css/ui-grid.css', 'bower_components/lodash/dist/lodash.min.js', 'bower_components/csv-js/csv.js']
unit: ['bower_components/jquery/jquery.min.js', 'lib/test/jquery.simulate.js','lib/test/classList.polyFill.js', 'dist/release/ui-grid.css', 'bower_components/lodash/dist/lodash.min.js', 'bower_components/csv-js/csv.js']
},

testFiles: {
Expand All @@ -25,9 +28,6 @@ var util = module.exports = {

// Return a list of angular files for a specific version
angularFiles: function (version) {
// Get the list of angular files (angular.js, angular-mocks.js, etc)
var cachedAngularFiles = grunt.file.readJSON('lib/test/angular/files.json');

if (version === 'latest') {
version = util.latestAngular();
}
Expand Down
2 changes: 1 addition & 1 deletion misc/demo/col-swap.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta content="width=device-width" name="viewport">

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" />
<link href="/dist/release/css/ui-grid.css" rel="stylesheet">
<link href="/dist/release/ui-grid.css" rel="stylesheet">

<script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="/lib/test/angular/1.2.26/angular.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion misc/demo/filtertoggle.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta content="width=device-width" name="viewport">

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" />
<link href="/dist/release/css/ui-grid.css" rel="stylesheet">
<link href="/dist/release/ui-grid.css" rel="stylesheet">

<!-- <script src="//code.jquery.com/jquery-2.1.3.min.js"></script> -->
<script src="/lib/test/angular/1.2.26/angular.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion misc/demo/grid-accessiblility.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta content="width=device-width" name="viewport">

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" />
<link href="/dist/release/css/ui-grid.css" rel="stylesheet">
<link href="/dist/release/ui-grid.css" rel="stylesheet">

<!--<script src="https://code.jquery.com/jquery-1.11.1.js"></script>-->
<script src="/lib/test/angular/1.3.16/angular.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion misc/demo/grid-directive.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta content="width=device-width" name="viewport">

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" />
<link href="/dist/release/css/ui-grid.css" rel="stylesheet">
<link href="/dist/release/ui-grid.css" rel="stylesheet">

<!--<script src="https://code.jquery.com/jquery-1.11.1.js"></script>-->
<script src="/lib/test/angular/1.2.26/angular.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion misc/demo/grid-in-tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta content="width=device-width" name="viewport">

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<link href="/dist/release/css/ui-grid.css" rel="stylesheet">
<link href="/dist/release/ui-grid.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<!--<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>-->
<script src="/lib/test/angular/1.3.16/angular.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion misc/demo/grid-save.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta content="width=device-width" name="viewport">

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" />
<link href="/dist/release/css/ui-grid.css" rel="stylesheet">
<link href="/dist/release/ui-grid.css" rel="stylesheet">

<!--<script src="https://code.jquery.com/jquery-1.11.1.js"></script>-->
<script src="/lib/test/angular/1.2.26/angular.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion misc/demo/leak-testing.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta content="width=device-width" name="viewport">

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" />
<link href="/dist/release/css/ui-grid.css" rel="stylesheet">
<link href="/dist/release/ui-grid.css" rel="stylesheet">

<!--<script src="https://code.jquery.com/jquery-1.11.1.js"></script>-->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion misc/demo/modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<script src="http://ui-grid.info/docs/grunt-scripts/pdfmake.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/vfs_fonts.js"></script>
<script src="/dist/release/ui-grid.js"></script>
<link rel="stylesheet" href="/dist/release/css/ui-grid.css" type="text/css" />
<link rel="stylesheet" href="/dist/release/ui-grid.css" type="text/css" />
<style type="text/css">
.grid {
width: 100%;
Expand Down
Loading

0 comments on commit 19475ea

Please sign in to comment.