Skip to content

Commit

Permalink
chore: add version 1.0.28
Browse files Browse the repository at this point in the history
  • Loading branch information
nalancer08 committed Sep 9, 2024
1 parent 9aefdef commit e4b3a3c
Show file tree
Hide file tree
Showing 14 changed files with 4,059 additions and 68 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish to npm

on:
push:
branches:
- main

jobs:
release:
name: Publish
runs-on: ubuntu-latest

steps:
- name: Check out the repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm version patch
npm publish
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
dist/**
package.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/node_modules/
/node_modules/
node_modules/
20 changes: 16 additions & 4 deletions .grunt/build_styles_task.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
module.exports = function(grunt) {
grunt.registerTask('buildLess', 'Compile admin.less and add .section.less', function() {
let adminContent = grunt.file.read('assets/styles/less/admin.less');

// -- Functions
function getCleanedCWD() {
const cwd = process.cwd();
return cwd
.replace('/node_modules', '')
.replace('/vanilla-jet', '')
.replace('/.grunt', '');
}
console.log('cwd 1: ', getCleanedCWD());

// -- Content
let adminContent = grunt.file.read(`${getCleanedCWD()}/assets/styles/less/admin.less`);
let sectionFiles = grunt.file.expand([
'assets/styles/less/sections/**/*.section.less',
'assets/styles/less/sections/*.section.less'
`${getCleanedCWD()}/assets/styles/less/sections/**/*.section.less`,
`${getCleanedCWD()}/assets/styles/less/sections/*.section.less`
]);

let combinedContent = adminContent + '\n';
Expand All @@ -13,7 +25,7 @@ module.exports = function(grunt) {
});

// -- New file
grunt.file.write('assets/styles/less/admin_build.less', combinedContent);
grunt.file.write(`${getCleanedCWD()}/assets/styles/less/admin_build.less`, combinedContent);
grunt.task.run(['less']);
});
};
23 changes: 15 additions & 8 deletions .grunt/compile_html.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ const path = require("path"),
nunjucks = require('nunjucks'),
identifier = 'templates';

let Functions = require('../core/external/functions.js');
let Dipper = require('../core/framework/dipper.js');
let Config = require('../core/external/config.js');
let Functions = require('../framework/functions.js');
let Dipper = require('../framework/dipper.js');
let Config = require(processCwd() + '/config.js');

// -- Get environment
let env = process.argv[2] || 'development';
if (env === 'dev') { env = 'development'; }
if (env === 'build:qa') { env = 'qa'; }
if (env === 'build:prod') { env = 'production'; }

// -- Init Dipper
const env = process.argv[2] || 'development';
let settings = Config.settings;
settings['shared']['environment'] = env;

Expand All @@ -31,7 +36,7 @@ nunjucks.configure(nunjucksPath, {
});

// -- Template directory
const templatesDirectoryPath = '../assets/templates/';
const templatesDirectoryPath = '/assets/templates/';

// -- Call main function
main();
Expand Down Expand Up @@ -126,7 +131,7 @@ function getTemplates(directory) {
}

// -- Main code
const templatesPath = path.join(__dirname, directory);
const templatesPath = path.join(processCwd(), directory);
exploreDirectory(templatesPath);
return results;
}
Expand Down Expand Up @@ -196,7 +201,7 @@ async function createHTMLFile(content, filePath) {
fs.mkdirSync(publicPath, { recursive: true });
const absolutePath = path.join(publicPath, filePath);
fs.writeFileSync(absolutePath, minified, 'utf8');
console.log(`Html file created at: ${absolutePath}`);
console.log(`Html :) file created at: ${absolutePath}`);
}

// -- Helpers
Expand All @@ -208,5 +213,7 @@ function cleanALine(line) {
}

function processCwd() {
return process.cwd().replace('/.grunt', '');
return process.cwd()
.replace('/.grunt', '')
.replace('/node_modules/vanilla-jet', '');
}
48 changes: 48 additions & 0 deletions .scripts/generate_packages_json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// -- Vars
const path = require("path"),
fs = require("fs");

// -- Main function
async function main() {

// -- Create the object to be write in the file
const json = {
coreDependencies: {
"modernizr": "//cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js",
"respond": "//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js",
"jquery": "//cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js",
"underscore": "//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.13.6/underscore-min.js"
},
dependencies: {},
styles: {},
fonts: {},
anims: {}
};
//console.log(json);
console.log("Creating the package.json file...");

// -- Create the file
await createFileIfnotExists(JSON.stringify(json, null, 2));
}

// -- Step 0
async function createFileIfnotExists(content) {

const fileName = 'vanillaJet.package.json';
const filePath = path.join(processCwd(), '/' + fileName);
const exists = await fs.promises.access(filePath, fs.constants.F_OK).then(() => true).catch(() => false);

if (!exists) {
// -- Create the file with the json content
fs.writeFileSync(filePath, content, 'utf8');
}
}

// -- Helpers
function processCwd() {
return process.cwd()
.replace('/.grunt', '')
.replace('/.scripts', '');
}

module.exports = main;
99 changes: 66 additions & 33 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = function(grunt) {
//compress: 'grunt-contrib-compress',
clean: 'grunt-contrib-clean'
});
grunt.option('force', true);

// -- Load modules
grunt.loadNpmTasks('grunt-contrib-cssmin');
Expand All @@ -14,10 +15,33 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-run');
require('./.grunt/build_styles_task')(grunt);

// -- Functions
function getCleanedCWD() {
const cwd = process.cwd();
let newCwd = cwd
.replace('/node_modules', '')
.replace('/vanilla-jet', '')
.replace('/.grunt', '');
//console.log('cwd: ', newCwd);
return newCwd;
}


// -- Vars
const cssDestination = `${getCleanedCWD()}/public/styles/app.min.css`;
const cssOrigin = `${getCleanedCWD()}/assets/styles/less/admin_build.less`;
const jsDestination = `${getCleanedCWD()}/public/`;

// -- Init
grunt.initConfig({
clean: {
build: ['public/scripts/vanilla.min.js'],
minified: ['public/scripts/api', 'public/scripts/controllers', 'public/scripts/views', 'public/scripts/app.min.js']
build: [`${getCleanedCWD()}/public/scripts/vanilla.min.js`],
minified: [
`${getCleanedCWD()}/public/scripts/api`,
`${getCleanedCWD()}/public/scripts/controllers`,
`${getCleanedCWD()}/public/scripts/views`,
`${getCleanedCWD()}/public/scripts/app.min.js`
],
//minified: ['public/scripts/**/*.min.js', 'public/scripts/*', '!public/scripts/vanilla.min.js']
},
less: {
Expand All @@ -29,7 +53,7 @@ module.exports = function(grunt) {
strictImports: true
},
files: {
'public/styles/app.min.css' : 'assets/styles/less/admin_build.less'
[cssDestination] : cssOrigin
},
}
},
Expand All @@ -39,10 +63,10 @@ module.exports = function(grunt) {
},
styles: {
files: [
'assets/styles/less/*.less',
'assets/styles/less/**/*.less',
'assets/styles/less/**/**/*.less',
'!assets/styles/less/admin_build.less'
`${getCleanedCWD()}/assets/styles/less/*.less`,
`${getCleanedCWD()}/assets/styles/less/**/*.less`,
`${getCleanedCWD()}/assets/styles/less/**/**/*.less`,
`${getCleanedCWD()}/!assets/styles/less/admin_build.less`
],
tasks: ['buildLess'],
options: {
Expand All @@ -51,17 +75,21 @@ module.exports = function(grunt) {
},
scripts: {
files: [
'assets/pages/*.html',
'assets/templates/**/*.html',
'assets/templates/**/**/*.html',
'external/view/*.js',
'external/*.js',
'framework/*.js'
`${getCleanedCWD()}/assets/pages/*.html`,
`${getCleanedCWD()}/assets/templates/**/*.html`,
`${getCleanedCWD()}/assets/templates/**/**/*.html`,
`${getCleanedCWD()}/external/view/*.js`,
`${getCleanedCWD()}/external/*.js`,
`${getCleanedCWD()}/framework/*.js`
],
tasks: ['shell:compileTemplates']
},
specificScripts: {
files: ['assets/scripts/*.js', 'assets/scripts/**/*.js', 'assets/scripts/**/**/*.js'],
files: [
`${getCleanedCWD()}/assets/scripts/*.js`,
`${getCleanedCWD()}/assets/scripts/**/*.js`,
`${getCleanedCWD()}/assets/scripts/**/**/*.js`
],
tasks: ['uglify', 'clean:build', 'concat', 'clean:minified']
}
},
Expand All @@ -86,20 +114,21 @@ module.exports = function(grunt) {
files: [{
expand: true,
src: [
'assets/scripts/*.js',
'assets/scripts/**/*.js',
'assets/scripts/**/**/*.js',
'assets/scripts/**/**/**/*.js'
`${getCleanedCWD()}/assets/scripts/*.js`,
`${getCleanedCWD()}/assets/scripts/**/*.js`,
`${getCleanedCWD()}/assets/scripts/**/**/*.js`,
`${getCleanedCWD()}/assets/scripts/**/**/**/*.js`
],
dest: 'public/',
cwd: '',
dest: getCleanedCWD() + '/public',
rename : function (dest, src) {

var folder = src.substring(0, src.lastIndexOf('/')),
filename = src.substring(src.lastIndexOf('/'), src.length);
filename = filename.substring(0, filename.lastIndexOf('.'));
folder = folder.replaceAll('assets', '');
return dest + folder + filename + '.min.js';
folder = folder.replaceAll('assets/', 'public/');
let file = folder + filename + '.min.js';
//console.log('file: ', file);
return file;
}
}]
}
Expand All @@ -108,17 +137,17 @@ module.exports = function(grunt) {
build: {
src: [
// Order
'public/scripts/controllers/**/*.min.js',
'public/scripts/views/**/*.min.js',
'public/scripts/api/**/*.min.js',
'public/scripts/*.min.js',
`${getCleanedCWD()}/public/scripts/controllers/**/*.min.js`,
`${getCleanedCWD()}/public/scripts/views/**/*.min.js`,
`${getCleanedCWD()}/public/scripts/api/**/*.min.js`,
`${getCleanedCWD()}/public/scripts/*.min.js`,

// Ignore files
'!public/scripts/core/**',
'!public/scripts/plugins/**',
'!public/scripts/plugins/ui/**'
`!${getCleanedCWD()}/public/scripts/core/**`,
`!${getCleanedCWD()}/public/scripts/plugins/**`,
`!${getCleanedCWD()}/public/scripts/plugins/ui/**`
],
dest: 'public/scripts/vanilla.min.js'
dest: `${getCleanedCWD()}/public/scripts/vanilla.min.js`
}
},
compress: {
Expand All @@ -128,7 +157,7 @@ module.exports = function(grunt) {
},
files: [{
expand: true,
src: ['public/scripts/vanilla.min.js'],
src: [`${getCleanedCWD()}/public/scripts/vanilla.min.js`],
dest: '',
ext: '.min.js.gz'
}]
Expand All @@ -141,7 +170,11 @@ module.exports = function(grunt) {
}
});

grunt.registerTask('default', ['buildLess', 'uglify', 'clean:build', 'concat', 'clean:minified', 'shell:compileTemplates', 'watch']);
grunt.registerTask('build', ['buildLess', 'uglify', 'clean:build', 'concat', 'clean:minified', 'shell:compileTemplates']);
grunt.registerTask('cleanForce', function(target) {
grunt.option('force', true);
grunt.task.run('clean:' + target);
});
grunt.registerTask('default', ['buildLess', 'uglify', 'cleanForce:build', 'concat', 'cleanForce:minified', 'shell:compileTemplates', 'watch']);
grunt.registerTask('build', ['buildLess', 'uglify', 'cleanForce:build', 'concat', 'cleanForce:minified', 'shell:compileTemplates']);
grunt.registerTask('server', ['buildLess']);
};
Loading

0 comments on commit e4b3a3c

Please sign in to comment.