Skip to content

Commit

Permalink
Fix NPM build for Typescript-fetch (#3403)
Browse files Browse the repository at this point in the history
* -Fix bug in fetch -> Missing "runtime"
-Move fetch files to an "src" folder instead of doing everything at the root which removes the bugs when using the library itself
-Fix the distribution of fetch using npm

* Move the .ts files to an `src` folder which is more common in npm package

* Add missing mustache

* Add missing .npmignore
  • Loading branch information
JFCote authored and macjohnny committed Aug 6, 2019
1 parent b8295af commit 9e659d1
Show file tree
Hide file tree
Showing 78 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public TypeScriptFetchClientCodegen() {
outputFolder = "generated-code/typescript-fetch";
embeddedTemplateDir = templateDir = "typescript-fetch";

this.apiPackage = "apis";
this.apiPackage = "src" + File.separator +"apis";
this.modelPackage = "src" + File.separator + "models";
this.apiTemplateFiles.put("apis.mustache", ".ts");
this.modelPackage = "models";
this.modelTemplateFiles.put("models.mustache", ".ts");
this.addExtraReservedWords();

Expand Down Expand Up @@ -84,8 +84,8 @@ public void processOpts() {
super.processOpts();
additionalProperties.put("isOriginalModelPropertyNaming", getModelPropertyNaming().equals("original"));
additionalProperties.put("modelPropertyNaming", getModelPropertyNaming());
supportingFiles.add(new SupportingFile("index.mustache", "", "index.ts"));
supportingFiles.add(new SupportingFile("runtime.mustache", "", "runtime.ts"));
supportingFiles.add(new SupportingFile("index.mustache", "src", "index.ts"));
supportingFiles.add(new SupportingFile("runtime.mustache", "src", "runtime.ts"));
supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json"));
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));

Expand Down Expand Up @@ -188,6 +188,7 @@ private void addNpmPackageGeneration() {
//Files for building our lib
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
supportingFiles.add(new SupportingFile("npmignore.mustache", "", ".npmignore"));
}

@Override
Expand Down Expand Up @@ -216,7 +217,7 @@ private void addOperationModelImportInfomation(Map<String, Object> operations) {
// models for a given operation.
List<Map<String, Object>> imports = (List<Map<String, Object>>) operations.get("imports");
for (Map<String, Object> im : imports) {
im.put("className", im.get("import").toString().replace("models.", ""));
im.put("className", im.get("import").toString().replace(modelPackage() + ".", ""));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"scripts" : {
"build": "tsc --outDir dist/",
"build": "tsc",
"prepare": "npm run build"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
"rootDir": ".",
{{^supportsES6}}
"lib": [
"es6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
"rootDir": ".",
"lib": [
"es6",
"dom"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"scripts" : {
"build": "tsc --outDir dist/",
"build": "tsc",
"prepare": "npm run build"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
"rootDir": ".",
"typeRoots": [
"node_modules/@types"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
"rootDir": ".",
"lib": [
"es6",
"dom"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
"rootDir": ".",
"lib": [
"es6",
"dom"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"scripts" : {
"build": "tsc --outDir dist/",
"build": "tsc",
"prepare": "npm run build"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
"rootDir": ".",
"lib": [
"es6",
"dom"
Expand Down

0 comments on commit 9e659d1

Please sign in to comment.