Skip to content

Commit c6711d7

Browse files
author
Rafael Grigorian
committed
Updated Docker enviorment and updated Grunt file
1 parent f78dfe0 commit c6711d7

File tree

3 files changed

+172
-83
lines changed

3 files changed

+172
-83
lines changed

Gruntfile.js

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
module.exports = function ( grunt ) {
2+
3+
// Import the package settings and the staging configuration
4+
var package = require ("./package.json");
5+
6+
// Load NPM tasks so we can use them in our configuration
7+
grunt.loadNpmTasks ("grunt-contrib-clean");
8+
grunt.loadNpmTasks ("grunt-contrib-compress");
9+
grunt.loadNpmTasks ("grunt-contrib-watch");
10+
grunt.loadNpmTasks ("grunt-git");
11+
grunt.loadNpmTasks ("grunt-replace");
12+
grunt.loadNpmTasks ("grunt-mkdir");
13+
grunt.loadNpmTasks ("grunt-rsync");
14+
15+
grunt.task.registerTask ( "default", "preform a full build", [ "release" ]);
16+
17+
grunt.task.registerTask ( "deploy", "upload src contents to staging environment", function () {
18+
// Initialize the rsync option object
19+
var _rsync_options = {
20+
args: [ "-az", "-o", "-g" ],
21+
exclude: [],
22+
recursive: true
23+
};
24+
// Save it into grunt config
25+
grunt.config.set ( "rsync.options", _rsync_options );
26+
// Initialize the rsync staging options
27+
var _rsync_staging = {
28+
src: "src/*",
29+
dest: "staging/"
30+
};
31+
// Save it into grunt config
32+
grunt.config.set ( "rsync.staging.options", _rsync_staging );
33+
// Run the task and upload the main source files
34+
grunt.task.run ( "rsync:staging" );
35+
});
36+
37+
grunt.task.registerTask ( "stream", "watch src and lib folders, deploy on change", function () {
38+
// Initialize the watch task options
39+
grunt.config.set ( "watch.module.files", [ "src/**/*", "lib/*/src/**/*" ] );
40+
grunt.config.set ( "watch.module.tasks", [ "deploy" ] );
41+
grunt.config.set ( "watch.module.options.spawn", false );
42+
// Run the task
43+
grunt.task.run ( "watch:module" );
44+
});
45+
46+
grunt.task.registerTask ( "version", "update version, defined in package.json", function () {
47+
// Initialize the replacement patterns
48+
var _patterns = [
49+
{
50+
match: /^(\s*\*\s+@version\s+)([0-9]+\.[0-9]+\.[0-9]+)(\s*)$/gm,
51+
replacement: "$1" + package.version + "$3"
52+
},
53+
{
54+
match: /^(\s*<version>)([0-9]+\.[0-9]+\.[0-9]+)(<\/version>\s*)$/gm,
55+
replacement: "$1" + package.version + "$3"
56+
}
57+
];
58+
// Initialize which files are effected
59+
var _files = [
60+
{
61+
expand: true,
62+
flatten: false,
63+
src: [ "src/**/*.php", "src/**/*.phtml", "src/**/*.xml" ],
64+
dest: "."
65+
}
66+
];
67+
// Update the options in grunt config
68+
grunt.config.set ( "replace.version.options.patterns", _patterns );
69+
grunt.config.set ( "replace.version.files", _files );
70+
// Run the replace task
71+
grunt.task.run ( "replace:version" );
72+
});
73+
74+
grunt.task.registerTask ( "init", "initialize file structure", function () {
75+
// If no arguments are passed set the default config
76+
if ( arguments.length == 0 ) {
77+
grunt.config.set ( "mkdir.execute.options.create", [ "dist" ] );
78+
grunt.task.run ( "mkdir:execute" );
79+
}
80+
// Check to see if there is one argument
81+
else if ( arguments.length == 1 ) {
82+
grunt.config.set ( "mkdir.execute.options.create", [ arguments [ 0 ] ] );
83+
grunt.task.run ( "mkdir:execute" );
84+
}
85+
// Warn user if there is more than one argument
86+
else {
87+
grunt.log.writeln ( this.name + ": No argument or one argument is valid" );
88+
}
89+
});
90+
91+
grunt.task.registerTask ( "nuke", "clear generated file structure", function () {
92+
// If no arguments are passed set the default config
93+
if ( arguments.length == 0 ) {
94+
grunt.config.set ( "clean.execute", [ "dist", "lib" ] );
95+
grunt.task.run ( "clean:execute" );
96+
}
97+
// Check to see if there is one argument
98+
else if ( arguments.length == 1 ) {
99+
var paths = [ arguments [ 0 ] + "/**", arguments [ 0 ] + "/.*" ];
100+
grunt.config.set ( "clean.execute", paths );
101+
grunt.task.run ( "clean:execute" );
102+
}
103+
// Warn user if there is more than one argument
104+
else {
105+
grunt.log.writeln ( this.name + ": No argument or one argument is valid" );
106+
}
107+
});
108+
109+
grunt.task.registerTask ( "release", "prepares file structure for github release", function () {
110+
// Run the dependency tasks
111+
grunt.task.run ( "init" );
112+
// Change version numbers
113+
grunt.task.run ( "version" );
114+
// Clear dist folder
115+
grunt.task.run ( "nuke:dist" );
116+
// Initialize the files array for compression
117+
var files = [
118+
{
119+
cwd: "src",
120+
expand: true,
121+
src: ["**"]
122+
},
123+
{
124+
src: [ "package.xml"]
125+
}
126+
];
127+
// Define the output file
128+
var company = package.company.replace ( "®", "" );
129+
var name = package.name.replace ( "-", "_" );
130+
var version = package.version;
131+
var _output = company + "_" + name + "-" + version + ".tgz";
132+
// Define other options
133+
grunt.config.set ( "compress.module.options.archive", "dist/" + _output );
134+
grunt.config.set ( "compress.module.options.mode", "tgz" );
135+
grunt.config.set ( "compress.module.files", files );
136+
// Compress the module
137+
grunt.task.run ( "compress:module" );
138+
});
139+
140+
};

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ services:
3838
image: jetrails/magento:2.x-cron
3939
hostname: cron.magento
4040
working_dir: /var/www/html
41-
command: /run-cron.sh
41+
command: run-cron.sh
4242
volumes_from:
4343
- filesystem
4444
environment:

gruntfile.js

Lines changed: 31 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,23 @@ module.exports = function ( grunt ) {
1515
grunt.task.registerTask ( "default", "preform a full build", [ "release" ]);
1616

1717
grunt.task.registerTask ( "deploy", "upload src contents to staging environment", function () {
18-
// Make sure that staging object is set in package JSON file
19-
if ( package.hasOwnProperty ( "staging" ) && package.staging.user.trim () != ""
20-
&& package.staging.host.trim () != "" && package.staging.port.trim () != ""
21-
&& package.staging.dest.trim () != "" ) {
22-
// Initialize the rsync option object
23-
var _rsync_options = {
24-
args: [ "-az", "-o", "-g", "-e 'ssh -p " + package.staging.port + "'" ],
25-
exclude: [],
26-
recursive: true
27-
}
28-
// Save it into grunt config
29-
grunt.config.set ( "rsync.options", _rsync_options );
30-
// Traverse through jetrails dependencies
31-
package.jetrailsDependencies.forEach ( function ( dependency ) {
32-
// Extract the dependency name
33-
var name = dependency.match (/\/([a-zA-Z0-9-]*)\.git$/) [ 1 ].toLowerCase ();
34-
// Initialize the rsync dependencies options
35-
var _rsync_dependencies = {
36-
src: "lib/" + name + "/src/*",
37-
dest: package.staging.dest,
38-
host: package.staging.user + "@" + package.staging.host
39-
}
40-
// Configure the dependency rsync options
41-
grunt.config.set ( "rsync." + name + ".options", _rsync_dependencies );
42-
// Run the dependencies task
43-
grunt.task.run ( "rsync:" + name + "" );
44-
});
45-
// Initialize the rsync staging options
46-
var _rsync_staging = {
47-
src: "src/*",
48-
dest: package.staging.dest,
49-
host: package.staging.user + "@" + package.staging.host
50-
}
51-
// Save it into grunt config
52-
grunt.config.set ( "rsync.staging.options", _rsync_staging );
53-
// Run the task and upload the main source files
54-
grunt.task.run ( "rsync:staging" );
55-
}
56-
// Otherwise, report that we cannot deploy
57-
else {
58-
grunt.log.writeln ( "could not find staging details in package.json" );
59-
}
18+
// Initialize the rsync option object
19+
var _rsync_options = {
20+
args: [ "-az", "-o", "-g" ],
21+
exclude: [],
22+
recursive: true
23+
};
24+
// Save it into grunt config
25+
grunt.config.set ( "rsync.options", _rsync_options );
26+
// Initialize the rsync staging options
27+
var _rsync_staging = {
28+
src: "src/*",
29+
dest: "staging/"
30+
};
31+
// Save it into grunt config
32+
grunt.config.set ( "rsync.staging.options", _rsync_staging );
33+
// Run the task and upload the main source files
34+
grunt.task.run ( "rsync:staging" );
6035
});
6136

6237
grunt.task.registerTask ( "stream", "watch src and lib folders, deploy on change", function () {
@@ -99,7 +74,7 @@ module.exports = function ( grunt ) {
9974
grunt.task.registerTask ( "init", "initialize file structure", function () {
10075
// If no arguments are passed set the default config
10176
if ( arguments.length == 0 ) {
102-
grunt.config.set ( "mkdir.execute.options.create", [ "src", "dist", "lib" ] );
77+
grunt.config.set ( "mkdir.execute.options.create", [ "dist" ] );
10378
grunt.task.run ( "mkdir:execute" );
10479
}
10580
// Check to see if there is one argument
@@ -131,61 +106,35 @@ module.exports = function ( grunt ) {
131106
}
132107
});
133108

134-
grunt.task.registerTask ( "resolve", "downloads jetrails dependency extensions", function () {
135-
// Run the dependency command
136-
grunt.task.run ( "init" );
137-
// Loop through all the dependencies
138-
package.jetrailsDependencies.forEach ( function ( dependency ) {
139-
// Extract the dependency name
140-
var name = dependency.match (/\/([a-zA-Z0-9-]*)\.git$/) [ 1 ].toLowerCase ();
141-
// Check to see if we already cloned the repository
142-
if ( grunt.file.exists ( "lib", name ) ) {
143-
// Nuke it
144-
grunt.task.run ( "nuke:lib" );
145-
}
146-
// Set the configuration, and clone it into lib
147-
grunt.task.run ( "init:lib/" + name );
148-
grunt.config.set ( "gitclone." + name + ".options.repository", dependency );
149-
grunt.config.set ( "gitclone." + name + ".options.directory", "lib/" + name );
150-
grunt.task.run ( "gitclone:" + name );
151-
});
152-
});
153-
154109
grunt.task.registerTask ( "release", "prepares file structure for github release", function () {
155110
// Run the dependency tasks
156111
grunt.task.run ( "init" );
157-
grunt.task.run ( "resolve" );
158112
// Change version numbers
159113
grunt.task.run ( "version" );
160114
// Clear dist folder
161115
grunt.task.run ( "nuke:dist" );
162116
// Initialize the files array for compression
163-
var files = [{
164-
cwd: "src",
165-
expand: true,
166-
src: ["**"]
167-
}];
168-
// Traverse through jetrails dependencies
169-
package.jetrailsDependencies.forEach ( function ( dependency ) {
170-
// Extract the dependency name
171-
var name = dependency.match (/\/([a-zA-Z0-9-]*)\.git$/) [ 1 ].toLowerCase ();
172-
// Append to the files array
173-
files.push ({
174-
cwd: "lib/" + name + "/src",
117+
var files = [
118+
{
119+
cwd: "src",
175120
expand: true,
176121
src: ["**"]
177-
});
178-
});
122+
},
123+
{
124+
src: [ "package.xml"]
125+
}
126+
];
179127
// Define the output file
180-
var _output = package.name.replace ( "-", "_" ) + ".zip";
128+
var company = package.company.replace ( "®", "" );
129+
var name = package.name.replace ( "-", "_" );
130+
var version = package.version;
131+
var _output = company + "_" + name + "-" + version + ".tgz";
181132
// Define other options
182133
grunt.config.set ( "compress.module.options.archive", "dist/" + _output );
183-
grunt.config.set ( "compress.module.options.mode", "zip" );
134+
grunt.config.set ( "compress.module.options.mode", "tgz" );
184135
grunt.config.set ( "compress.module.files", files );
185136
// Compress the module
186137
grunt.task.run ( "compress:module" );
187-
// Nuke the lib folder
188-
grunt.task.run ( "nuke:lib" );
189138
});
190139

191140
};

0 commit comments

Comments
 (0)