Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the sequence into LF from CRLF #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 91 additions & 93 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,93 +1,91 @@
#!/usr/bin/env node

const fs = require("fs-extra");
const path = require("path");
console.log("Revery Packager v" + require("./package.json").version);

const args = require("yargs")
.argv;

let projectDir = process.cwd();

if (args.project) {
projectDir = args.project;
}

console.log(" - Packaging project: " + projectDir);

const releaseDir = path.join(projectDir, "_release");
const platformReleaseDir = path.join(releaseDir, process.platform);

console.log(" - Placing release artifacts in: " + platformReleaseDir);

const packageJsonPath = path.join(projectDir, "package.json");

if (!fs.existsSync(packageJsonPath)) {
throw "No package.json found at: " + packageJsonPath;
};

const packageInfo = require(packageJsonPath);

console.log(" - Checking esy status...");

const esy = require("./src/esy");

const isBuilt = esy.isBuilt(projectDir);

if (!isBuilt) {
throw "Esy project must be built prior to packaging.";
}

console.log (" - Esy isBuilt: true");

const workingDirectory = projectDir;
const binPath = esy.getEsyVariable(workingDirectory, "self.bin");
const reveryBinPath = esy.getEsyVariable(workingDirectory, "revery.bin");

console.log(" - Project bin path: " + binPath);
console.log(" - Revery bin path: " + reveryBinPath);


let macBundlerPath = null;
if (process.platform == "darwin") {
let macBundlerDir = esy.getEsyVariable(workingDirectory, "esy-macdylibbundler.bin");
macBundlerPath = path.join(macBundlerDir, "dylibbundler");

// TODO: Can we do something better, like bundle esy-dylibbundler with this project?
if (!fs.existsSync(macBundlerPath)) {
throw "esy-macdylibbundler must be a dependency of the project.";
}
console.log(" - Mac bundler path: " + macBundlerPath);
}

console.log("Created _release directory");
fs.removeSync(platformReleaseDir);
fs.mkdirpSync(platformReleaseDir);

esy.ensureInstalled(workingDirectory);

const bundleInfo = require("./src/bundle").getBundleInfo(packageInfo);

const config = {
projectDir,
releaseDir,
platformReleaseDir,
bundleInfo,
packageInfo,
binPath,
reveryBinPath,
macBundlerPath,
};

const run = async () => {

if (process.platform == "win32") {
await require("./src/package-windows")(config);
} else if (process.platform == "darwin") {
await require("./src/package-darwin")(config);
} else {
await require("./src/package-linux")(config);
}
};

run();
#!/usr/bin/env node

const fs = require("fs-extra");
const path = require("path");
console.log("Revery Packager v" + require("./package.json").version);

const args = require("yargs")
.argv;

let projectDir = process.cwd();

if (args.project) {
projectDir = args.project;
}

console.log(" - Packaging project: " + projectDir);

const releaseDir = path.join(projectDir, "_release");
const platformReleaseDir = path.join(releaseDir, process.platform);

console.log(" - Placing release artifacts in: " + platformReleaseDir);

const packageJsonPath = path.join(projectDir, "package.json");

if (!fs.existsSync(packageJsonPath)) {
throw "No package.json found at: " + packageJsonPath;
};

const packageInfo = require(packageJsonPath);

console.log(" - Checking esy status...");

const esy = require("./src/esy");

const isBuilt = esy.isBuilt(projectDir);

if (!isBuilt) {
throw "Esy project must be built prior to packaging.";
}

console.log (" - Esy isBuilt: true");

const workingDirectory = projectDir;
const binPath = esy.getEsyVariable(workingDirectory, "self.bin");
const reveryBinPath = esy.getEsyVariable(workingDirectory, "revery.bin");

console.log(" - Project bin path: " + binPath);
console.log(" - Revery bin path: " + reveryBinPath);

let macBundlerPath = null;
if (process.platform == "darwin") {
let macBundlerDir = esy.getEsyVariable(workingDirectory, "esy-macdylibbundler.bin");
macBundlerPath = path.join(macBundlerDir, "dylibbundler");

// TODO: Can we do something better, like bundle esy-dylibbundler with this project?
if (!fs.existsSync(macBundlerPath)) {
throw "esy-macdylibbundler must be a dependency of the project.";
}
console.log(" - Mac bundler path: " + macBundlerPath);
}

console.log("Created _release directory");
fs.removeSync(platformReleaseDir);
fs.mkdirpSync(platformReleaseDir);

esy.ensureInstalled(workingDirectory);

const bundleInfo = require("./src/bundle").getBundleInfo(packageInfo);

const config = {
projectDir,
releaseDir,
platformReleaseDir,
bundleInfo,
packageInfo,
binPath,
reveryBinPath,
macBundlerPath,
};

const run = async () => {
if (process.platform == "win32") {
await require("./src/package-windows")(config);
} else if (process.platform == "darwin") {
await require("./src/package-darwin")(config);
} else {
await require("./src/package-linux")(config);
}
};

run();
130 changes: 65 additions & 65 deletions src/bundle.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
// Bundle.js
//
// Utilities for reading the bundle information from package json
const path = require("path");
const fs = require("fs-extra");
const defaultBundleInfo = {
// On Mac, this is the name of the app bundle. For example,
// if bundleName is "ExampleApp", the output App would be "Example.App"
bundleName: "ReveryApp",
// On Mac, this is the bundle id used in the plist
bundleId: "com.example.revery",
displayName: "Revery App",
// Main executable should be the primary executable, WITHOUT the '.exe' extension.
mainExecutable: "App",
// Packages - list of package formats to output:
packages: ["zip", "tar", "dmg", "appimage"],
// MAC ONLY: The background to use for the dmg
dmgBackground: path.join(__dirname, "..", "assets", "dmg-background.png"),
appImageType: "Application",
appImageCategory: "Development",
// Path to icon file
// Windows: An .ico file is expected
// OSX: An .icns file is expected
iconFile: path.join(__dirname, "..", "assets", "revery-icon.png"),
};
const getBundleInfo = (packageJson) => {
let platform;
if (process.platform == "win32") {
platform = "win32";
} else if (process.platform == "darwin") {
platform = "darwin"
} else {
platform = "linux"
}
let commonBundleInfo = packageJson["revery-packager"] || {};
let platformBundleInfo = {};
if (commonBundleInfo[platform]) {
platformBundleInfo = commonBundleInfo[platform];
}
return {
...defaultBundleInfo,
...commonBundleInfo,
...platformBundleInfo
};
};
module.exports = {
getBundleInfo
};
// Bundle.js
//
// Utilities for reading the bundle information from package json

const path = require("path");
const fs = require("fs-extra");

const defaultBundleInfo = {
// On Mac, this is the name of the app bundle. For example,
// if bundleName is "ExampleApp", the output App would be "Example.App"
bundleName: "ReveryApp",

// On Mac, this is the bundle id used in the plist
bundleId: "com.example.revery",

displayName: "Revery App",

// Main executable should be the primary executable, WITHOUT the '.exe' extension.
mainExecutable: "App",

// Packages - list of package formats to output:
packages: ["zip", "tar", "dmg", "appimage"],

// MAC ONLY: The background to use for the dmg
dmgBackground: path.join(__dirname, "..", "assets", "dmg-background.png"),


appImageType: "Application",
appImageCategory: "Development",

// Path to icon file
// Windows: An .ico file is expected
// OSX: An .icns file is expected
iconFile: path.join(__dirname, "..", "assets", "revery-icon.png"),
};

const getBundleInfo = (packageJson) => {

let platform;
if (process.platform == "win32") {
platform = "win32";
} else if (process.platform == "darwin") {
platform = "darwin"
} else {
platform = "linux"
}

let commonBundleInfo = packageJson["revery-packager"] || {};

let platformBundleInfo = {};

if (commonBundleInfo[platform]) {
platformBundleInfo = commonBundleInfo[platform];
}

return {
...defaultBundleInfo,
...commonBundleInfo,
...platformBundleInfo
};
};

module.exports = {
getBundleInfo
};
81 changes: 40 additions & 41 deletions src/esy.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@

const cp = require("child_process");

const esyCommand = process.platform == "win32" ? "esy.cmd" : "esy";

const runEsyCommand = (workingDirectory, args) => {
console.log("ESY: Running esy command: " + args.join(" ") + " in " + workingDirectory);

const result = cp.spawnSync(esyCommand, args, { cwd: workingDirectory, env: process.env});
if (!result) {
return null;
} else if (!result.stdout) {
return null;
} else {
const out = result.stdout.toString("utf-8").trim();
return out;
}
};

const getEsyVariable = (workingDirectory, variableName) => {
return runEsyCommand(workingDirectory, ["echo", "#{" + variableName +"}"]);
};

const isBuilt = (workingDirectory) => {
const json = runEsyCommand(workingDirectory, ["status"]);
if (!json) {
return false;
}

return JSON.parse(json).isProjectReadyForDev;
};

const ensureInstalled = (workingDirectory) => {
runEsyCommand(workingDirectory, ["x", "echo"]);
};

module.exports = {
ensureInstalled,
getEsyVariable,
isBuilt,
};
const cp = require("child_process");

const esyCommand = process.platform == "win32" ? "esy.cmd" : "esy";

const runEsyCommand = (workingDirectory, args) => {
console.log("ESY: Running esy command: " + args.join(" ") + " in " + workingDirectory);

const result = cp.spawnSync(esyCommand, args, { cwd: workingDirectory, env: process.env});
if (!result) {
return null;
} else if (!result.stdout) {
return null;
} else {
const out = result.stdout.toString("utf-8").trim();
return out;
}
};

const getEsyVariable = (workingDirectory, variableName) => {
return runEsyCommand(workingDirectory, ["echo", "#{" + variableName +"}"]);
};

const isBuilt = (workingDirectory) => {
const json = runEsyCommand(workingDirectory, ["status"]);
if (!json) {
return false;
}

return JSON.parse(json).isProjectReadyForDev;
};

const ensureInstalled = (workingDirectory) => {
runEsyCommand(workingDirectory, ["x", "echo"]);
};

module.exports = {
ensureInstalled,
getEsyVariable,
isBuilt,
};
Loading