Skip to content

Commit

Permalink
prep for build (Azure#2600)
Browse files Browse the repository at this point in the history
  • Loading branch information
fearthecowboy authored and olydis committed Sep 21, 2017
1 parent 7c2546c commit 2070a48
Show file tree
Hide file tree
Showing 12 changed files with 342 additions and 226 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,5 @@ Samples/**/*.map
**/package-lock.json
src/*/dist
src/*/nm
/nm/
/nm/
*.tgz
3 changes: 3 additions & 0 deletions .gulp/typescript.iced
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ copyDtsFiles = (done) =>
# copy *.d.ts files
source ["#{basefolder}/src/autorest-core/dist/**/*.d.ts","!#{basefolder}/src/autorest-core/dist/test/**" ]
.pipe destination "#{basefolder}/src/autorest/lib/core"
.on 'end', () =>
source ["#{basefolder}/src/autorest-core/dist/**/*.d.ts","!#{basefolder}/src/autorest-core/dist/test/**" ]
.pipe destination "#{basefolder}/src/autorest/dist/lib/core"
.on 'end', done
return null

Expand Down
12 changes: 8 additions & 4 deletions src/autorest-core/lib/autorest-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ export class AutoRest extends EventEmitter {
}

public static async LiterateToJson(content: string): Promise<string> {
try {
let autorest = new AutoRest({
EnumerateFileUris: async function (folderUri: string): Promise<Array<string>> { return []; },
ReadFile: async (f: string): Promise<string> => f == "mem:///foo.md" ? content : ""
ReadFile: async (f: string): Promise<string> => f == "none:///empty-file.md" ? content || "# empty file" : "# empty file"
});
let result = "";
autorest.AddConfiguration({ "input-file": "mem:///foo.md", "output-artifact": ["swagger-document"] });
autorest.AddConfiguration({ "input-file": "none:///empty-file.md", "output-artifact": ["swagger-document"] });
autorest.GeneratedFile.Subscribe((source, artifact) => {
result = artifact.content;
});
// run autorest and wait.
try {

await (await autorest.Process()).finish;
return result;
} catch (x) {
Expand Down Expand Up @@ -91,7 +92,6 @@ export class AutoRest extends EventEmitter {
return Configuration.DetectConfigurationFile(fileSystem, (documentPath || null));
}


/**
* Event: Signals when a Process() finishes.
*/
Expand All @@ -116,6 +116,7 @@ export class AutoRest extends EventEmitter {
}

/**
* @internal
* @param fileSystem The implementation of the filesystem to load and save files from the host application.
* @param configFileOrFolderUri The URI of the configuration file or folder containing the configuration file. Is null if no configuration file should be looked for.
*/
Expand All @@ -125,6 +126,9 @@ export class AutoRest extends EventEmitter {
process.env["autorest.home"] = process.env["autorest.home"] || homedir();
}

public static create(fileSystem?: IFileSystem, configFileOrFolderUri?: string) {
return new AutoRest(fileSystem, configFileOrFolderUri);
}
public async RegenerateView(includeDefault: boolean = false): Promise<ConfigurationView> {
this.Invalidate();
const messageEmitter = new MessageEmitter();
Expand Down
24 changes: 24 additions & 0 deletions src/autorest-core/lib/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,30 @@ export class ConfigurationView {
break;
}

// fix the source names
for (const source of mx.Source || []) {

if (source.Position) {
try {
source.document = this.DataStore.ReadStrictSync(source.document).Description;
} catch (e) {

}
}
}

// fix the source names in Ranges too
for (const range of mx.Range || []) {
if (range.document) {
try {
range.document = this.DataStore.ReadStrictSync(range.document).Description;
} catch (e) {

}
}
}


this.messageEmitter.Message.Dispatch(mx);
}
} catch (e) {
Expand Down
6 changes: 5 additions & 1 deletion src/autorest-core/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/usr/bin/env node
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

// enable static modules for autorest-core
if ((<any>global).StaticVolumeSet) {
(<any>global).StaticVolumeSet.addFileSystem(`${__dirname}/static_modules.fs`)
}

export { IFileSystem } from "./lib/file-system"
export { Message, Channel } from "./lib/message"
export { AutoRest, ConfigurationView } from "./lib/autorest-core"
Expand Down
2 changes: 1 addition & 1 deletion src/autorest-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft.azure/autorest-core",
"version": "2.0.4",
"version": "2.0.5",
"description": "AutoRest core module",
"engines": {
"node": ">=7.10.0"
Expand Down
Loading

0 comments on commit 2070a48

Please sign in to comment.