Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.

Commit 649ecf3

Browse files
authored
Merge pull request #66 from atomist/pkg-conversion
Get everything working without manifest.yml
2 parents f4d0d31 + 43e2fdf commit 649ecf3

File tree

56 files changed

+1702
-2605
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1702
-2605
lines changed

.atomist/build/travis-build.bash

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
set -o pipefail
55

66
declare Pkg=travis-build
7-
declare Version=0.7.0
7+
declare Version=0.8.0
88

99
function msg() {
1010
echo "$Pkg: $*"
@@ -59,27 +59,23 @@ function main () {
5959
rug="$rug --timer --quiet --update --resolver-report --error --settings=$PWD/.atomist/build/cli.yml"
6060
export TEAM_ID=T1L0VDKJP
6161

62-
if [[ -f .atomist/package.json ]]; then
63-
msg "running yarn"
64-
# this should use --frozen-lockfile but
65-
# https://github.com/yarnpkg/yarn/issues/3313
66-
if ! ( cd .atomist && yarn --pure-lockfile ); then
67-
err "yarn failed"
68-
return 1
69-
fi
62+
msg "running npm install"
63+
if ! ( cd .atomist && npm install ); then
64+
err "npm install failed"
65+
return 1
66+
fi
7067

71-
msg "running lint"
72-
if ! ( cd .atomist && yarn run lint ); then
73-
err "tslint failed"
74-
return 1
75-
fi
68+
msg "running lint"
69+
if ! ( cd .atomist && npm run lint ); then
70+
err "tslint failed"
71+
return 1
72+
fi
7673

77-
if [[ -d .atomist/mocha ]]; then
78-
msg "running mocha tests"
79-
if ! ( cd .atomist && yarn run mocha ); then
80-
err "mocha tests failed"
81-
return 1
82-
fi
74+
if [[ -d .atomist/mocha ]]; then
75+
msg "running mocha tests"
76+
if ! ( cd .atomist && npm run mocha ); then
77+
err "mocha tests failed"
78+
return 1
8379
fi
8480
fi
8581

@@ -98,15 +94,10 @@ function main () {
9894
[[ $TRAVIS_PULL_REQUEST == false ]] || return 0
9995

10096
local archive_version
101-
local manifest=.atomist/manifest.yml
102-
if [[ -f $manifest ]]; then
103-
archive_version=$(awk -F: '$1 == "version" { print $2 }' "$manifest" | sed 's/[^.0-9]//g')
104-
else
105-
err "no manifest.yml in archive"
106-
return 1
107-
fi
97+
local pkg_json=.atomist/package.json
98+
archive_version=$(jq -er .version "$pkg_json")
10899
if [[ $? -ne 0 || ! $archive_version ]]; then
109-
err "failed to extract archive version: $archive_version"
100+
err "failed to extract archive version from $pkg_json: $archive_version"
110101
return 1
111102
fi
112103
local project_version

.atomist/editors/AddFunctions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { PathExpressionEngine } from "@atomist/rug/tree/PathExpression";
3030
*/
3131
export function addInstructionsToReadMe(project: Project, instructions: string): void {
3232
const readme = project.findFile("README.md");
33-
if (readme === null || !readme.containsMatch("\n## Rugs[\\S\\s]*\n## Support")) {
33+
if (readme == null || !readme.containsMatch("\n## Rugs[\\S\\s]*\n## Support")) {
3434
return;
3535
}
3636
readme.regexpReplace("\n## Support", instructions + "\n## Support");

.atomist/editors/AddLocalEditor.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@ import { Editor, Parameter, Tags } from "@atomist/rug/operations/Decorators";
1919
import { EditProject } from "@atomist/rug/operations/ProjectEditor";
2020
import { Pattern } from "@atomist/rug/operations/RugOperation";
2121

22+
import { isRugArchive } from "./RugEditorsPredicates";
2223
import { RugParameters } from "./RugParameters";
2324

25+
/**
26+
* Add an editor for modifying the local project. Useful when you
27+
* editors are specific to a project and you want to store them with
28+
* the project.
29+
*/
2430
@Editor("AddLocalEditor", "adds an editor for modifying the local project, initiating a Rug archive if needed")
2531
@Tags("rug", "atomist", "typescript")
2632
export class AddLocalEditor implements EditProject {
@@ -44,18 +50,13 @@ export class AddLocalEditor implements EditProject {
4450
public groupId: string = "local";
4551

4652
public edit(project: Project) {
47-
project.editWith("ConvertExistingProjectToRugArchive", {
48-
description: this.description,
49-
archiveName: project.name,
50-
groupId: this.groupId,
51-
});
52-
project.editWith("AddTypeScript", {});
53-
if (!project.directoryExists(".atomist/node_modules")) {
54-
// The following line works with the CLI but when used through the
55-
// bot, it often triggers GitHub rate limiting.
56-
// project.copyEditorBackingFilesPreservingPath(".atomist/node_modules");
53+
if (!isRugArchive(project)) {
54+
project.editWith("ConvertExistingProjectToRugArchive", {
55+
description: this.description,
56+
archiveName: project.name,
57+
groupId: this.groupId,
58+
});
5759
}
58-
5960
project.editWith("AddTypeScriptEditor", this);
6061
}
6162
}

.atomist/editors/AddManifestYml.ts

Lines changed: 0 additions & 80 deletions
This file was deleted.

.atomist/editors/AddTypeScript.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.

.atomist/editors/AddTypeScriptCommandHandler.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ import { EditProject } from "@atomist/rug/operations/ProjectEditor";
2222
import { isRugArchive, NotRugArchiveError } from "./RugEditorsPredicates";
2323
import { RugParameters } from "./RugParameters";
2424

25+
/**
26+
* Add a command handler to a Rug project. If the project is not a Rug project
27+
* an Error is thrown.
28+
*/
2529
@Editor("AddTypeScriptCommandHandler", "adds a TypeScript Rug command handler to a Rug project")
2630
@Tags("rug", "atomist", "typescript")
2731
export class AddTypeScriptCommandHandler implements EditProject {
@@ -55,8 +59,6 @@ export class AddTypeScriptCommandHandler implements EditProject {
5559
throw new NotRugArchiveError();
5660
}
5761

58-
project.editWith("AddTypeScript", {});
59-
6062
const srcHandlerName = "TypeScriptCommandHandler";
6163
const srcHandlerPath = `.atomist/handlers/command/${srcHandlerName}.ts`;
6264
const srcTestPath = `.atomist/tests/handlers/command/${srcHandlerName}Steps.ts`;

.atomist/editors/AddTypeScriptEditor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ import { addInstructionsToReadMe, readMeInstructions } from "./AddFunctions";
2323
import { isRugArchive, NotRugArchiveError } from "./RugEditorsPredicates";
2424
import { RugParameters } from "./RugParameters";
2525

26+
/**
27+
* Add a editor to a Rug project. If the project is not a Rug project
28+
* an Error is thrown.
29+
*/
2630
@Editor("AddTypeScriptEditor", "adds a TypeScript Rug editor to a Rug project")
2731
@Tags("rug", "atomist", "typescript")
2832
export class AddTypeScriptEditor implements EditProject {
@@ -47,8 +51,6 @@ export class AddTypeScriptEditor implements EditProject {
4751
throw new NotRugArchiveError();
4852
}
4953

50-
project.editWith("AddTypeScript", {});
51-
5254
const srcEditorName = "TypeScriptEditor";
5355
const srcEditorPath = `.atomist/editors/${srcEditorName}.ts`;
5456
const srcTestPath = `.atomist/tests/project/${srcEditorName}Steps.ts`;

.atomist/editors/AddTypeScriptEventHandler.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ import { EditProject } from "@atomist/rug/operations/ProjectEditor";
2222
import { isRugArchive, NotRugArchiveError } from "./RugEditorsPredicates";
2323
import { RugParameters } from "./RugParameters";
2424

25+
/**
26+
* Add an event handler to a Rug project. If the project is not a Rug project
27+
* an Error is thrown.
28+
*/
2529
@Editor("AddTypeScriptEventHandler", "adds a TypeScript Rug event handler to a Rug project")
2630
@Tags("rug", "atomist", "typescript")
2731
export class AddTypeScriptEventHandler implements EditProject {
@@ -56,8 +60,6 @@ export class AddTypeScriptEventHandler implements EditProject {
5660
throw new NotRugArchiveError();
5761
}
5862

59-
project.editWith("AddTypeScript", {});
60-
6163
const srcHandlerName = "TypeScriptEventHandler";
6264
const srcHandlerPath = `.atomist/handlers/event/${srcHandlerName}.ts`;
6365
const srcTestPath = `.atomist/tests/handlers/event/${srcHandlerName}Steps.ts`;

.atomist/editors/AddTypeScriptGenerator.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ import { addInstructionsToReadMe, readMeInstructions } from "./AddFunctions";
2323
import { isRugArchive, NotRugArchiveError } from "./RugEditorsPredicates";
2424
import { RugParameters } from "./RugParameters";
2525

26+
/**
27+
* Add a generator to a Rug project. If the project is not a Rug project
28+
* an Error is thrown.
29+
*/
2630
@Editor("AddTypeScriptGenerator", "adds a TypeScript generator to a Rug project")
2731
@Tags("rug", "atomist", "typescript")
2832
export class AddTypeScriptGenerator implements EditProject {
@@ -46,8 +50,6 @@ export class AddTypeScriptGenerator implements EditProject {
4650
throw new NotRugArchiveError();
4751
}
4852

49-
project.editWith("AddTypeScript", {});
50-
5153
const srcGeneratorName = "TypeScriptGenerator";
5254
const srcGeneratorPath = `.atomist/generators/${srcGeneratorName}.ts`;
5355
const srcTestPath = ".atomist/tests/project/TypeScriptGeneratorSteps.ts";

.atomist/editors/BumpVersion.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ import { Project } from "@atomist/rug/model/Project";
1818
import { Editor, Parameter, Tags } from "@atomist/rug/operations/Decorators";
1919
import { EditProject } from "@atomist/rug/operations/ProjectEditor";
2020

21+
import { isRugArchive, NotRugArchiveError } from "./RugEditorsPredicates";
22+
2123
/**
22-
* Increment the Rug archive version in manifest.yml
24+
* Increment the Rug archive version in .atomist/package.json.
2325
*/
2426
@Editor("BumpVersion", "bump the version of this Rug archive project")
2527
@Tags("rug", "version")
@@ -37,25 +39,29 @@ export class BumpVersion implements EditProject {
3739
public component: string = "minor";
3840

3941
public edit(project: Project) {
40-
const manifest = project.findFile(".atomist/manifest.yml");
41-
if (manifest == null) {
42-
const err = "project does not appear to be a Rug project";
42+
if (!isRugArchive(project)) {
43+
throw new NotRugArchiveError();
44+
}
45+
const pkgJsonPath = ".atomist/package.json";
46+
const pkgJson = project.findFile(pkgJsonPath);
47+
if (pkgJson == null) {
48+
const err = `failed to open file: ${pkgJsonPath}`;
4349
console.log(err);
4450
throw new Error(err);
4551
}
4652

47-
const extractVersionRegex = /^version\s*:\s*(?:"(.*?)"|(.*))\s*$/m;
48-
const versionMatch = extractVersionRegex.exec(manifest.content);
53+
const extractVersionRegex = /"version"\s*:\s*"(.*?)"/;
54+
const versionMatch = extractVersionRegex.exec(pkgJson.content);
4955
if (!versionMatch) {
50-
const err = `unable to extract version from manifest.yml: ${manifest.content}`;
56+
const err = `unable to extract version from ${pkgJsonPath}: ${pkgJson.content}`;
5157
console.log(err);
5258
throw new Error(err);
5359
}
5460

5561
const comp = this.component as "major" | "minor" | "patch";
56-
const newVersion = incrementVersion(versionMatch[1] || versionMatch[2], comp);
62+
const newVersion = incrementVersion(versionMatch[1], comp);
5763

58-
manifest.regexpReplace("version:.*", `version: "${newVersion}"`);
64+
pkgJson.regexpReplace(`"version"\\s*:\\s*".*?"`, `"version": "${newVersion}"`);
5965
}
6066
}
6167

@@ -71,7 +77,7 @@ export function incrementVersion(version: string, component: "major" | "minor" |
7177
let major = parseInt(versionMatch[1], 10);
7278
let minor = parseInt(versionMatch[2], 10);
7379
let patch = parseInt(versionMatch[3], 10);
74-
const rest = (versionMatch[4] !== null && versionMatch[4] !== undefined) ? versionMatch[4] : "";
80+
const rest = (versionMatch[4] != null) ? versionMatch[4] : "";
7581

7682
if (component === "major") {
7783
major = major + 1;

0 commit comments

Comments
 (0)