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

Commit 1979f9f

Browse files
author
David Dooling
committed
AddTypeScript adds node_modules directory
To avoid requiring users to install NPM and run `npm install`, we include the node_modules directory when adding TypeScript support to a Rug project using the AddTypeScript editor. Migrate AddTypeScript editor to TypeScript. Export constants (`const`) rather than variables (`let`) from TypeScript Rugs.
1 parent d297c9d commit 1979f9f

File tree

9 files changed

+82
-79
lines changed

9 files changed

+82
-79
lines changed

.atomist.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,19 @@ editor:
103103
parameters:
104104
- "editor_name": "AddAtomistCopyright"
105105

106+
---
107+
kind: "operation"
108+
client: "rug-cli 0.24.0"
109+
editor:
110+
name: "atomist-rugs.rug-editors.AddTypeScriptEditor"
111+
group: "atomist-rugs"
112+
artifact: "rug-editors"
113+
version: "0.9.0"
114+
origin:
115+
repo: "https://github.com/atomist-rugs/rug-editors.git"
116+
branch: "82acbef9ce2c04e0cb6316b9fde702a89469a85b"
117+
sha: "82acbef"
118+
parameters:
119+
- "editor_name": "AddTypeScript"
120+
- "description": "adds TypeScript supporting files to a Rug archive project"
121+

.atomist/editors/AddTypeScript.rug

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

.atomist/editors/AddTypeScript.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright © 2017 Atomist, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { EditProject } from '@atomist/rug/operations/ProjectEditor'
18+
import { Project } from '@atomist/rug/model/Core'
19+
import { Pattern } from '@atomist/rug/operations/RugOperation'
20+
import { Editor, Tags } from '@atomist/rug/operations/Decorators'
21+
22+
@Editor("AddTypeScript", "adds TypeScript supporting files to a Rug archive project")
23+
@Tags("rug", "typescript")
24+
class AddTypeScript implements EditProject {
25+
26+
edit(project: Project) {
27+
if (!project.fileExists(".atomist/manifest.yml")) {
28+
return;
29+
}
30+
31+
let packageJsonPath = ".atomist/package.json";
32+
let tsconfigJsonPath = ".atomist/tsconfig.json";
33+
let gitignorePath = ".atomist/.gitignore";
34+
let nodeModulesPath = ".atomist/node_modules";
35+
project.copyEditorBackingFileOrFail(packageJsonPath);
36+
project.copyEditorBackingFileOrFail(tsconfigJsonPath);
37+
project.copyEditorBackingFileOrFail(gitignorePath);
38+
project.copyEditorBackingFilesPreservingPath(nodeModulesPath);
39+
}
40+
}
41+
42+
export const addTypeScript = new AddTypeScript()

.atomist/editors/AddTypeScriptGenerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ class AddTypeScriptGenerator implements EditProject {
7979
}
8080
}
8181

82-
export let addTypeScriptGenerator = new AddTypeScriptGenerator()
82+
export const addTypeScriptGenerator = new AddTypeScriptGenerator()

.atomist/editors/HelloTypeScript.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ class HelloTypeScript implements EditProject {
2222
}
2323
}
2424

25-
export let helloTypeScript = new HelloTypeScript()
25+
export const helloTypeScript = new HelloTypeScript()

.atomist/editors/TypeScriptGenerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ class TypeScriptGenerator implements PopulateProject {
2323
}
2424
}
2525

26-
export let typeScriptGenerator = new TypeScriptGenerator();
26+
export const typeScriptGenerator = new TypeScriptGenerator();

.atomist/tests/AddTypeScript.rt

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2016 Atomist, Inc.
2+
* Copyright © 2017 Atomist, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,27 +31,8 @@ then
3131
and fileContains ".atomist/tsconfig.json" "suppressImplicitAnyIndexErrors"
3232
and fileExists ".atomist/.gitignore"
3333
and fileContains ".atomist/.gitignore" "node_modules"
34-
35-
36-
scenario AddTypeScript should add support files for writing Rugs in TypeScript with a specific version of Rug
37-
38-
let rug_version = "0.9.0"
39-
40-
given
41-
.atomist/manifest.yml = """requires: "0.11.0"
42-
"""
43-
44-
when
45-
AddTypeScript
46-
47-
then
48-
fileExists ".atomist/package.json"
49-
and fileContains ".atomist/package.json" '"@atomist/rug"'
50-
and fileContains ".atomist/package.json" '"0.9.0"'
51-
and fileExists ".atomist/tsconfig.json"
52-
and fileContains ".atomist/tsconfig.json" "suppressImplicitAnyIndexErrors"
53-
and fileExists ".atomist/.gitignore"
54-
and fileContains ".atomist/.gitignore" "node_modules"
34+
and directoryExists ".atomist/node_modules/@atomist/rug"
35+
and fileExists ".atomist/node_modules/@atomist/rug/model/Core.ts"
5536

5637

5738
scenario AddTypeScript should not make any changes if the target project is not a Rug archive

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10-
[Unreleased]: https://github.com/atomist-rugs/rug-editors/compare/0.9.0...HEAD
10+
[Unreleased]: https://github.com/atomist-rugs/rug-editors/compare/0.10.0...HEAD
11+
12+
## [0.10.0] - 2017-02-24
13+
14+
[0.10.0]: https://github.com/atomist-rugs/rug-editors/compare/0.9.0...0.10.0
15+
16+
### Added
17+
18+
- AddTypeScript adds .atomist/node_modules
1119

1220
### Changed
1321

1422
- AddTypeScript now adds an appropriate .gitignore
1523

24+
- AddTypeScript is now in TypeScript
25+
26+
- TypeScript Rugs export constants rather than variables
27+
1628
## [0.9.0] - 2017-02-17
1729

1830
[0.9.0]: https://github.com/atomist-rugs/rug-editors/compare/0.8.0...0.9.0

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,20 @@ satisfied.
129129

130130
#### Parameters
131131

132-
To run this Editor, you must supply the following parameters.
133-
134-
Name | Required | Default | Description
135-
-----|----------|---------|------------
136-
`rug_version` | No | 0.12.0 | A valid Rug version following NPM version semantics, https://docs.npmjs.com/misc/semver.
132+
This editor has no parameters.
137133

138134
#### Running
139135

140136
Run it as follows:
141137

142138
```
143139
$ cd rug/archive/directory
144-
$ rug edit atomist-rugs:rug-editors:AddTypeScript \
145-
rug_version=0.12.0
140+
$ rug edit atomist-rugs:rug-editors:AddTypeScript
146141
```
147142

148-
This will add the files `.atomist/package.json` and
149-
`.atomist/tsconfig.json` to the project.
143+
This will add `package.json`, `tsconfig.json`, and `.gitignore` files
144+
and the `node_modules` directory to the `.atomist` directory in the
145+
project.
150146

151147
### AddTypeScriptEditor
152148

0 commit comments

Comments
 (0)