Skip to content

Commit

Permalink
- Added new README.md
Browse files Browse the repository at this point in the history
- Added license to package.json
- Added README generator for SDK
- Added graphics for README
  • Loading branch information
DavidArayan committed Nov 21, 2023
1 parent 3522c40 commit 59d42e2
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
run: rm -rf sdk-core/src/version.ts && echo 'export default "${{ env.RELEASE_VERSION }}";' > sdk-core/src/version.ts
- name: copy README
run: cp README.md sdk-core/README.md
- name: copy graphics
run: cp -R graphics sdk-core/
- name: NPM Build
run: npm run --prefix sdk-core clean:build
- uses: JS-DevTools/npm-publish@v1
Expand Down
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
# api-sdk
Typescript SDK for interfacing with the Plattar V3 API
<h3 align="center">
<img src="graphics/logo.png?raw=true" alt="Plattar Logo" width="600">
</h3>

[![NPM](https://img.shields.io/npm/v/@plattar/sdk-core)](https://www.npmjs.com/package/@plattar/sdk-core)

_sdk-core_ is a generative & runtime support module for automatically generating a TypeScript SDK to interface with Plattar backend services

### Installation

- Install using [npm](https://www.npmjs.com/package/@plattar/sdk-core)

```console
npm install @plattar/sdk-core
```
Binary file added graphics/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions sdk-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"node": ">=18.0"
},
"author": "plattar",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/Plattar/sdk-core/issues"
},
Expand Down
2 changes: 2 additions & 0 deletions sdk-core/src/generator/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export class Generator {
await fs.promises.writeFile(`${outputDir}/${project.packageJson.fname}`, project.packageJson.data);
// write the .tsconfig file
await fs.promises.writeFile(`${outputDir}/${project.tsConfig.fname}`, project.tsConfig.data);
// write the README.md file
await fs.promises.writeFile(`${outputDir}/${project.readme.fname}`, project.readme.data);

// begin writing all source files
const allSchemas: Array<Promise<void>> = new Array<Promise<void>>();
Expand Down
19 changes: 19 additions & 0 deletions sdk-core/src/generator/generators/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export interface GeneratedProject {
readonly npmRc: {
readonly fname: string;
readonly data: string;
};
readonly readme: {
readonly fname: string;
readonly data: string;
}
}

Expand All @@ -46,6 +50,10 @@ export class Project {
npmRc: {
fname: '.npmrc',
data: "//registry.npmjs.org/:_authToken=${NPM_TOKEN}"
},
readme: {
fname: 'README.md',
data: Project.generateReadme(vars)
}
}
}
Expand Down Expand Up @@ -123,4 +131,15 @@ export class Project {
'package-lock.json',
'.npmrc'].join('\r\n');
}

public static generateReadme(vars: PackageJsonVars): string {
let output = `[![NPM](https://img.shields.io/npm/v/@plattar/${vars.name})](https://www.npmjs.com/package/@plattar/${vars.name})\n\n`;
output += `### About\n\n`;
output += `_${vars.name}_ v${vars.version} is automatically generated using [sdk-core](https://www.npmjs.com/package/@plattar/sdk-core) module\n\n`;
output += `### Installation\n\n`;
output += `- Install using [npm](https://www.npmjs.com/package/@plattar/${vars.name})\n\n`;
output += `\`\`\`console\nnpm install @plattar/${vars.name}\n\`\`\`\n`;

return output;
}
}

0 comments on commit 59d42e2

Please sign in to comment.