|
| 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() |
0 commit comments