Exemple #1
1
gulp.task('rainloop:setup', ['rainloop:copy'], function() {

	var
		versionFull = pkg.version + '.' + parseInt(pkg.release, 10),
		dist = cfg.releasesPath + '/webmail/' + versionFull + '/src/'
	;

	fs.writeFileSync(dist + 'data/VERSION', versionFull);
	fs.writeFileSync(dist + 'data/EMPTY', versionFull);

	fs.writeFileSync(dist + 'index.php',
		fs.readFileSync('index.php', 'utf8').replace('\'APP_VERSION\', \'0.0.0\'', '\'APP_VERSION\', \'' + versionFull + '\''));

	fs.writeFileSync(dist + 'rainloop/v/' + versionFull + '/index.php.root', fs.readFileSync(dist + 'index.php'));

	if (cfg.community)
	{
		require('rimraf').sync(dist + 'rainloop/v/' + versionFull + '/app/libraries/RainLoop/Prem/');
	}

	cfg.destPath = cfg.releasesPath + '/webmail/' + versionFull + '/';
	cfg.cleanPath = dist;
	cfg.zipSrcPath = dist;
	cfg.zipFile = 'rainloop-' + (cfg.community ? 'community-' : '') + versionFull + '.zip';
	cfg.md5File = cfg.zipFile;

	cfg.rainloopBuilded = true;
});
Exemple #2
0
Writer.prototype.write = function() {
  var parts = [this.baseDir];
  var args = _.flatten(arguments);

  for (var i=0; i<args.length-2; i++) {
    parts.push(args[i]);
  }

  var dirname = path.resolve.apply(null, parts);
  var filename = args[args.length - 2];
  var content = args[args.length - 1];

  if (this.leadingFileComments) {
    content = this.leadingFileComments + content;
  }

  if (this.trailingFileComments) {
    content = content + this.trailingFileComments;
  }

  fs.mkdirSync(dirname, parseInt('0770',8), true);

  fs.writeFileSync(path.resolve(dirname, filename), content);

  return this; // Allow chaining
}
Exemple #3
0
/**
 * Save the exif for the current image into a json file.
 * json - js object, basically just map of tags to values.
 * imgFile - path of image under test
 * program - name of program that extracted the exif (exiftool.js or Redaktor etc.)
 */
function saveJson(json, imgFile, program) {
    var pathString = json.img,
        trimmedImageName = imgFile.substring(imgFile.indexOf('sampleImages')),
        jsonFile = 'test/generated/json/' + program + '/' + trimmedImageName + '.json',
        parentDir = jsonFile.substring(0, jsonFile.lastIndexOf("/"));
    fs.mkdirSync(parentDir, '0777', true);
    fs.writeFileSync(jsonFile, JSON.stringify(json, null, '\t'));
}
Exemple #4
0
	function writeTemplate(template, context) {
		var result = mustache.render(
			fs.readFileSync(path.join(__dirname, '../templates/', template), 'ascii'),
			context
		);

		if (verbose) console.log("Writing:", path.join(context.buildDir, template.replace('.mustache', '')));

		fs.writeFileSync(path.join(context.buildDir, template.replace('.mustache', '')), result, 'ascii');
	}
gulp.task('rainloop:owncloud:setup', ['rainloop:owncloud:copy'], function() {

	var
		versionFull = pkg.ownCloudPackageVersion,
		dist = cfg.releasesPath + '/owncloud/' + versionFull + '/src/'
	;

	fs.writeFileSync(dist + 'rainloop/appinfo/info.xml',
		fs.readFileSync(dist + 'rainloop/appinfo/info.xml', 'utf8').replace('<version>0.0</version>', '<version>' + versionFull + '</version>'));

	fs.writeFileSync(dist + 'rainloop/appinfo/version', versionFull);
	fs.writeFileSync(dist + 'rainloop/VERSION', versionFull);

	cfg.destPath = cfg.releasesPath + '/owncloud/' + versionFull + '/';
	cfg.cleanPath = dist;
	cfg.zipSrcPath = dist;
	cfg.zipFile = 'rainloop-owncloud-app-' + versionFull + '.zip';
	cfg.md5File = cfg.zipFile;

});
Exemple #6
0
gulp.task('rainloop:owncloud:setup', ['rainloop:owncloud:copy', 'rainloop:owncloud:copy-rainloop'], function() {

	var
		versionFull = pkg.ownCloudPackageVersion,
		dist = cfg.releasesPath + '/owncloud/' + versionFull + '/src/'
	;

	fs.writeFileSync(dist + 'rainloop/appinfo/info.xml',
		fs.readFileSync(dist + 'rainloop/appinfo/info.xml', 'utf8')
			.replace('<version>0.0</version>', '<version>' + versionFull + '</version>')
			.replace('<licence></licence>', '<licence>' + (cfg.community ? 'AGPLv3' : 'RainLoop Software License') + '</licence>')
		);

	fs.writeFileSync(dist + 'rainloop/appinfo/version', versionFull);
	fs.writeFileSync(dist + 'rainloop/VERSION', versionFull);

	cfg.destPath = cfg.releasesPath + '/owncloud/' + versionFull + '/';
	cfg.cleanPath = dist;
	cfg.zipSrcPath = dist;
	cfg.zipFile = 'rainloop-owncloud-app-' + (cfg.community ? '' : 'standard-') + versionFull + '.zip';
	cfg.zipFileShort = 'rainloop' + (cfg.community ? '' : '-standard') + '.zip';
});
Exemple #7
0
function writeConfig(cmd) {
  var source, target;

  mode = 'writeConfig'

  source = cmd.source;
  target = cmd.target;

  if(source) config.source = source;
  if(target) config.target = target;

  fs.writeFileSync(configPath, JSON.stringify(config), 'utf-8');
  console.log('Wrote ledit config file to ', configPath)
}
gulp.task('rainloop:setup', ['rainloop:copy'], function() {

	var
		versionFull = pkg.version + '.' + parseInt(pkg.release, 10),
		dist = cfg.releasesPath + '/webmail/' + versionFull + '/src/'
	;

	fs.writeFileSync(dist + 'data/VERSION', versionFull);
	fs.writeFileSync(dist + 'data/EMPTY', versionFull);

	fs.writeFileSync(dist + 'index.php',
		fs.readFileSync('index.php', 'utf8').replace('\'APP_VERSION\', \'0.0.0\'', '\'APP_VERSION\', \'' + versionFull + '\''));

	fs.writeFileSync(dist + 'rainloop/v/' + versionFull + '/index.php.root', fs.readFileSync(dist + 'index.php'));

	fs.unlinkSync(dist + 'rainloop/v/' + versionFull + '/static/css/less.css');

	cfg.destPath = cfg.releasesPath + '/webmail/' + versionFull + '/';
	cfg.cleanPath = dist;
	cfg.zipSrcPath = dist;
	cfg.zipFile = 'rainloop-' + versionFull + '.zip';
	cfg.md5File = cfg.zipFile;
});
Exemple #9
0
  function copy(file) {
    var relativePath = path.relative(source, file);
    var targetLocation = path.resolve(target, relativePath);
    var targetDir = path.dirname(targetLocation);

    var sourceFile = fs.readFileSync(file);
    if (!fs.existsSync(targetDir)) {
      console.log(targetLocation);
      console.log(targetDir);
      console.log(fs.existsSync(targetDir));

      fs.mkdirSync(targetDir, 777, true);
    }
    fs.writeFileSync(targetLocation, sourceFile);
  }
  grunt.registerMultiTask('sort', 'Sort JSON API Files', function () {
    grunt.log.writeln('Sorting APIs');
    var logos = [];

    // organize apis into grouppings
    grunt.file.expand(this.data.src).forEach(function (api) {
      var data = grunt.file.readJSON(api);
      var group = data.id.charAt(0).toLowerCase();

      var dest = this.data.dest + path.sep + group + path.sep + data.id + path.sep;

      // create directories
      if (fs.exists(dest) === false) {
        fs.mkdirSync(dest, '0777', true);
      }

      // re-locate apis
      fs.renameSync(api, dest + 'api.json');
    }.bind(this));

    fs.writeFileSync('logos.json', JSON.stringify(logos, null, 2));
  });
Exemple #11
0
  lib.renderPostsAndPages = function (postCollection, cacheFile, done) {
    var templateData = { posts: postCollection };

    lib.setTemplateEngine();

    if (options.data) {
      lib.setData(templateData);
    }

    lib.setPostUrls(postCollection);

    postCollection.forEach(function (post) {
      post.dest = lib.getDestFromUrl(post.url);
    });

    lib.sortPosts(postCollection);

    var cachedPosts = _.cloneDeep(templateData);

    // Remove data that will not be passed to templates for rendering
    templateData.posts.forEach(function (post) {

      // Remove the lastModified attribute as it only used for caching
      delete post.lastModified;

      // Remove the source path from the post as it is only used for caching and error logging in getPostDest
      delete post.sourcePath;
    });

    // Record how long it takes to generate posts
    var postStart = new Date().getTime();

    lib.generatePosts(templateData);

    if (grunt.option('bench')) {
      console.log('\nPosts'.blue + ' took ' + (new Date().getTime() - postStart) / 1000 + ' seconds.\n');
    }

    // Record how long it takes to generate pages
    var pageStart = new Date().getTime();

    if (options.pageSrc) {
      lib.generatePages(templateData);
    }

    if (options.pagination) {
      if (Array.isArray(options.pagination)) {
        options.pagination.forEach(function (pagination) {
          lib.paginate(templateData, pagination);
        });
      } else {
        lib.paginate(templateData, options.pagination);
      }
    }

    if (grunt.option('bench')) {
      console.log('\nPages'.magenta + ' took ' + (new Date().getTime() - pageStart) / 1000 + ' seconds.\n');
    }

    if (options.rss) {
      lib.generateRSS(postCollection);
    }

    if (!fs.existsSync(path.dirname(cacheFile))) {
      fs.mkdirSync(path.dirname(cacheFile), '0777', true);
    }

    fs.writeFileSync(cacheFile, JSON.stringify(cachedPosts));

    if (grunt.option('bench')) {
      console.log('Task'.yellow + ' took ' + (new Date().getTime() - start) / 1000 + ' seconds.');
    }
    done();
  };
		res.on('end', function(){
			fs.writeFileSync(fileName, imagedata, 'binary' );
			transformImage(fileName, callback);
		});
Exemple #13
0
function copyFile(sFile, sNewFile, callback)
{
	fs.writeFileSync(sNewFile, fs.readFileSync(sFile));
	callback();
}
Exemple #14
0
function copyFile (file, location) {
  fs.mkdirSync((file).split('/').slice(0, -1).join('/'), 0x1ed, true)
  fs.writeFileSync(file, fs.readFileSync(location))
}
gulp.task('package-inc-release', function() {
	fs.writeFileSync('package.json',
		fs.readFileSync('package.json', 'utf8').replace(/"release":\s?"[\d]+",/, '"release": "' +
			(1 + parseInt(pkg.release, 10)) + '",'));
});