Search in sources :

Example 1 with ExampleFile

use of org.eclipse.n4js.cli.init.InitResources.ExampleFile in project n4js by eclipse.

the class N4jscInit method initProject.

private static N4jscExitState initProject(N4jscOptions options, InitConfiguration config) throws N4jscException {
    try {
        config.projectRoot.resolve(config.projectFolderSrc).toFile().mkdirs();
        config.projectRoot.resolve(config.projectFolderOutput).toFile().mkdirs();
        config.packageJson.write(options, config.projectRoot);
        for (ExampleFile exampleFile : config.files) {
            exampleFile.writeToDisk(config.projectRoot);
        }
    } catch (IOException e) {
        throw new N4jscException(N4jscExitCode.INIT_ERROR_WORKING_DIR, e);
    }
    return N4jscExitState.SUCCESS;
}
Also used : ExampleFile(org.eclipse.n4js.cli.init.InitResources.ExampleFile) IOException(java.io.IOException) N4jscException(org.eclipse.n4js.cli.N4jscException)

Example 2 with ExampleFile

use of org.eclipse.n4js.cli.init.InitResources.ExampleFile in project n4js by eclipse.

the class InitConfiguration method toStringYarn.

private String toStringYarn() {
    String str = "";
    str += "FILE TREE AT " + yarnRoot + NL;
    str += " ├── " + yarnRoot.relativize(workspacesDir) + NL;
    str += " │  └── " + workspacesDir.relativize(projectRoot) + NL;
    for (ExampleFile eFile : files) {
        str += " │     ├── " + eFile.getDir() + NL;
        str += " │     │  └── " + eFile.getName() + NL;
    }
    str += " │     └── package.json" + NL;
    str += " └── package.json" + NL;
    str += NL;
    Gson gson = JsonUtils.createGson();
    str += packageJson.exists ? (packageJson.hasModifications() ? "MODIFIED " : "UNMODIFIED ") : "";
    str += "CONTENTS OF package.json at " + yarnRoot.relativize(projectRoot) + NL;
    str += gson.toJson(packageJson) + NL;
    str += NL;
    str += yarnPackageJson.exists ? (yarnPackageJson.hasModifications() ? "MODIFIED " : "UNMODIFIED ") : "";
    str += "CONTENTS OF package.json at " + yarnRoot + NL;
    str += gson.toJson(yarnPackageJson) + NL;
    return str;
}
Also used : ExampleFile(org.eclipse.n4js.cli.init.InitResources.ExampleFile) Gson(com.google.gson.Gson)

Example 3 with ExampleFile

use of org.eclipse.n4js.cli.init.InitResources.ExampleFile in project n4js by eclipse.

the class InitConfiguration method toStringSingleProject.

private String toStringSingleProject() {
    String str = "";
    str += "FILE TREE AT " + projectRoot + NL;
    for (ExampleFile eFile : files) {
        str += " ├── " + eFile.getDir() + NL;
        str += " │  └── " + eFile.getName() + NL;
    }
    str += " └── package.json" + NL;
    str += NL;
    Gson gson = JsonUtils.createGson();
    str += packageJson.exists ? (packageJson.hasModifications() ? "MODIFIED " : "UNMODIFIED ") : "";
    str += "CONTENTS OF package.json";
    str += gson.toJson(packageJson) + NL;
    return str;
}
Also used : ExampleFile(org.eclipse.n4js.cli.init.InitResources.ExampleFile) Gson(com.google.gson.Gson)

Aggregations

ExampleFile (org.eclipse.n4js.cli.init.InitResources.ExampleFile)3 Gson (com.google.gson.Gson)2 IOException (java.io.IOException)1 N4jscException (org.eclipse.n4js.cli.N4jscException)1