Skip to content

Commit

Permalink
readme config
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaozha committed Nov 20, 2020
1 parent 2a3d434 commit 1ae94a5
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.history
dist
node_modules
package-lock.json
*.tgz
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
# autorest.config
# configuration

See documentation [here](doc/00-onboarding-guide.md)

``` yaml

pipeline-model: v3

pipeline:
configPlugin/generate:
input:
- openapi-document/multi-api/identity
output-artifact: config-extension
configPlugin/emitter:
input:
- configPlugin/generate
scope: scope-config-plugin

scope-config-plugin:
is-object: false
output-artifact:
- config-extension
output-folder: $(config-output-folder)
```
43 changes: 43 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "@qiaozha/autorest.config",
"version": "0.1.0",
"description": "Autorest Azure AZ extension",
"main": "dist/index.js",
"engines": {
"node": ">=10.12.0"
},
"scripts": {
"start": "node dist/index.js",
"debug": "node --max_old_space_size=4096 --inspect-brk ./dist/index.js",
"eslint-fix": "eslint . --fix --ext .ts",
"eslint": "eslint . --ext .ts",
"build": "tsc -p .",
"start-testserver": "./node_modules/.bin/start-autorest-testserver",
"stop-testserver": "./node_modules/.bin/stop-autorest-testserver",
"watch": "tsc -p . --watch",
"prepare": "npm run build",
"test": "npm run build && mocha dist/test",
"clean": "ver > nul 2>&1 nul && npm run --silent clean-cmd || npm run --silent clean-bash",
"clean-cmd": "if exist dist rmdir /s /q dist && exit 0 || exit 0 ",
"clean-bash": "rm nul && rm -rf dist && exit 0 || exit 0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Azure/autorest.config.git"
},
"keywords": [
"autorest",
"extension"
],
"author": "Microsoft Corporation",
"license": "MIT",
"devDependencies": {},
"dependencies": {
"@azure-tools/autorest-extension-base": "~3.1.235",
"@azure-tools/codemodel": "^4.13.348",
"@types/node": "^14.14.8"
},
"files": [
"dist"
]
}
13 changes: 13 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CodeModel, codeModelSchema, Language, Parameter } from "@azure-tools/codemodel";
import { Session, startSession, Host, Channel } from "@azure-tools/autorest-extension-base";


export async function processRequest(host: Host) {
try {
const session = await startSession<CodeModel>(host, {}, codeModelSchema);
let config = await session.getValue("");
host.WriteFile('autorest_configuration.json', JSON.stringify(config));
} catch (E) {
throw E;
}
}
18 changes: 18 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { AutoRestExtension, Channel, Host } from "@azure-tools/autorest-extension-base";
import { processRequest as config } from './config'


export type LogCallback = (message: string) => void;
export type FileCallback = (path: string, rows: string[]) => void;

export async function initializePlugins(pluginHost: AutoRestExtension) {
pluginHost.Add('generate', config);
}

export async function configPlugin() {
const extension = new AutoRestExtension();
await initializePlugins(extension);
extension.Run();
}

configPlugin();
19 changes: 19 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"lib": [
"es2016",
"dom"
],
"outDir": "dist",
"module": "commonjs",
"sourceMap": true,
"types": [
"node"
],
"target": "es2016",
"experimentalDecorators": true
},
"include": [
"src"
]
}

0 comments on commit 1ae94a5

Please sign in to comment.