mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-09 08:28:45 +00:00
* Tests/Manual/*/Info.plist: Set CPDefaultTheme to Aristo3 across all manual test applications, including those previously overriding to Aristo2. * Tests/Manual/*/Jakefile: Add an orchestration task to update CPDefaultTheme (e.g., npx jake theme "Aristo3 Dark"). For testing convenience. * Tests/Manual/*/Jakefile (Narwhal format): Migrate module imports and execution calls to Node equivalents from the capp application template, and remove syntax artifacts.
154 lines
5.4 KiB
JavaScript
154 lines
5.4 KiB
JavaScript
/*
|
|
* Jakefile
|
|
* ArrayControllerRemovingFirstTest
|
|
*
|
|
* Created by You on July 17, 2012.
|
|
* Copyright 2012, Your Company All rights reserved.
|
|
*/
|
|
|
|
var ENV = process.env,
|
|
cp = require("child_process"),
|
|
fs = require("fs"),
|
|
path = require("path"),
|
|
task = JAKE.task,
|
|
FileList = JAKE.FileList,
|
|
app = CAPPUCCINO.Jake.applicationtask.app,
|
|
configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug";
|
|
|
|
app ("ArrayControllerRemovingFirstTest", function(task)
|
|
{
|
|
task.setBuildIntermediatesPath(path.join("Build", "ArrayControllerRemovingFirstTest.build", configuration));
|
|
task.setBuildPath(path.join("Build", configuration));
|
|
|
|
task.setProductName("ArrayControllerRemovingFirstTest");
|
|
task.setIdentifier("com.yourcompany.ArrayControllerRemovingFirstTest");
|
|
task.setVersion("1.0");
|
|
task.setAuthor("Your Company");
|
|
task.setEmail("feedback @nospam@ yourcompany.com");
|
|
task.setSummary("ArrayControllerRemovingFirstTest");
|
|
task.setSources((new FileList("**/*.j")).exclude(path.join("Build", "**")));
|
|
task.setResources(new FileList("Resources/**"));
|
|
task.setIndexFilePath("index.html");
|
|
task.setInfoPlistPath("Info.plist");
|
|
|
|
if (configuration === "Debug")
|
|
task.setCompilerFlags("-DDEBUG -g");
|
|
else
|
|
task.setCompilerFlags("-O");
|
|
});
|
|
|
|
task ("default", ["ArrayControllerRemovingFirstTest"], function()
|
|
{
|
|
printResults(configuration);
|
|
});
|
|
|
|
task ("build", ["default"]);
|
|
|
|
task ("debug", function()
|
|
{
|
|
ENV["CONFIGURATION"] = "Debug";
|
|
JAKE.subjake(["."], "build", ENV);
|
|
});
|
|
|
|
task ("release", function()
|
|
{
|
|
ENV["CONFIGURATION"] = "Release";
|
|
JAKE.subjake(["."], "build", ENV);
|
|
});
|
|
|
|
task ("run", ["debug"], function()
|
|
{
|
|
cp.execSync(["open", path.join("Build", "Debug", "ArrayControllerRemovingFirstTest", "index.html")].join(" "), { stdio: "inherit" });
|
|
});
|
|
|
|
task ("run-release", ["release"], function()
|
|
{
|
|
cp.execSync(["open", path.join("Build", "Release", "ArrayControllerRemovingFirstTest", "index.html")].join(" "), { stdio: "inherit" });
|
|
});
|
|
|
|
task ("deploy", ["release"], function()
|
|
{
|
|
fs.mkdirSync(path.join("Build", "Deployment", "ArrayControllerRemovingFirstTest"), { recursive: true });
|
|
cp.execSync(["press", "-f", path.join("Build", "Release", "ArrayControllerRemovingFirstTest"), path.join("Build", "Deployment", "ArrayControllerRemovingFirstTest")].join(" "), { stdio: "inherit" });
|
|
printResults("Deployment")
|
|
});
|
|
|
|
task ("desktop", ["release"], function()
|
|
{
|
|
fs.mkdirSync(path.join("Build", "Desktop", "ArrayControllerRemovingFirstTest"), { recursive: true });
|
|
require("@objj/nativehost").buildNativeHost(path.join("Build", "Release", "ArrayControllerRemovingFirstTest"), path.join("Build", "Desktop", "ArrayControllerRemovingFirstTest", "ArrayControllerRemovingFirstTest.app"));
|
|
printResults("Desktop")
|
|
});
|
|
|
|
task ("run-desktop", ["desktop"], function()
|
|
{
|
|
cp.execSync([path.join("Build", "Desktop", "ArrayControllerRemovingFirstTest", "ArrayControllerRemovingFirstTest.app", "Contents", "MacOS", "NativeHost"), "-i"].join(" "), { stdio: "inherit" });
|
|
});
|
|
|
|
function printResults(configuration)
|
|
{
|
|
console.log("----------------------------");
|
|
console.log(configuration+" app built at path: "+path.join("Build", configuration, "ArrayControllerRemovingFirstTest"));
|
|
console.log("----------------------------");
|
|
}
|
|
|
|
task ("clean", function()
|
|
{
|
|
cp.execSync("rm -rf Build", { stdio: "inherit" });
|
|
});
|
|
|
|
task ("clobber", ["clean"], function()
|
|
{
|
|
cp.execSync("rm -rf Frameworks", { stdio: "inherit" });
|
|
});
|
|
|
|
/*
|
|
Sets the theme this application uses, for example:
|
|
|
|
npx jake theme Aristo2
|
|
npx jake theme "Aristo3 Dark"
|
|
|
|
The name is written to CPDefaultTheme in Info.plist as given, with its case
|
|
kept and &, < and > escaped. Empty the browser cache afterwards, because the
|
|
browser keeps the old Info.plist.
|
|
|
|
Jake runs each word on the command line as a task, in order, and looks a task
|
|
up only when it reaches it. So this task declares the theme name as an empty
|
|
task, which Jake then runs without effect. A name that is already a task is
|
|
refused, because Jake would run that task after this one. So is a name that
|
|
starts with ^ or jake:, which Jake reads as a task scope.
|
|
*/
|
|
JAKE.task ("theme", function()
|
|
{
|
|
var fs = require("fs"),
|
|
path = require("path"),
|
|
themeName = process.argv[process.argv.indexOf("theme") + 1],
|
|
plistPath = path.join(__dirname, "Info.plist"),
|
|
themeKey = /(<key>CPDefaultTheme<\/key>\s*<string>)[^<]*(<\/string>)/;
|
|
|
|
if (!themeName || !themeName.trim())
|
|
throw new Error("Give a theme name, for example: npx jake theme \"Aristo3 Dark\"");
|
|
|
|
if (/^(\^|jake:)/.test(themeName))
|
|
throw new Error("A theme name cannot start with ^ or jake:, which Jake reads as a task scope");
|
|
|
|
if (JAKE.application().lookup(themeName))
|
|
throw new Error(themeName + " is a task in this Jakefile, not a theme name");
|
|
|
|
var plist = fs.readFileSync(plistPath, "utf8"),
|
|
plistValue = themeName.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
|
|
if (!themeKey.test(plist))
|
|
throw new Error("No CPDefaultTheme key in " + plistPath);
|
|
|
|
plist = plist.replace(themeKey, function(match, head, tail)
|
|
{
|
|
return head + plistValue + tail;
|
|
});
|
|
|
|
fs.writeFileSync(plistPath, plist);
|
|
JAKE.task(themeName);
|
|
|
|
console.log("Theme set to " + themeName + " in " + plistPath);
|
|
});
|