<reponame>luketio/emissionapis
#!/usr/bin/python

import os


Project_Name = input("Enter API name: ")
ProjectName = Project_Name.replace(" ", "")
projectname = ProjectName.lower()

LICENSE = f"""
// Copyright (c) 2021 <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// opies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

"""

INDEX_TS = f"""export namespace {projectname} {{
  export interface Options {{}}

  export class {ProjectName} {{
    options: Options;

    constructor(options: Options) {{
      this.options = options;
    }}
  }}
}}
"""

README_MD = f"""# {Project_Name}
### [API]()
## Usage

```sh
$ npm install @emissionapis/{projectname}
$ yarn install @emissionapis/{projectname}
```
```js
const {{ {projectname} }} = require("@emissionapis/{projectname}");
import {{ {projectname} }} from "@emissionapis/{projectname}";
```

**<NAME> <<EMAIL>>**

* Website: https://ltgr.github.io
* Github: [@ltgr](https://github.com/ltgr)
## License

Copyright © 2021 [<NAME> <<EMAIL>>](https://github.com/ltgr).<br />
This project is [MIT](https://github.com/ltgr/emissionapis/blob/main/LICENSE) licensed.

*Crafted with ❤️ by <NAME>*

"""

PACKAGE_JSON = f"""{{
  "name": "@emissionapis/{projectname}",
  "homepage": "https://github.com/ltgr/emissionapis/tree/main/src/apis/{projectname}",
  "version": "0.1.0",
  "author": "<NAME>",
  "license": "MIT",
  "description": "{projectname}",
  "repository": {{
    "type": "git",
    "url": "git+https://github.com/ltgr/emissionapis.git"
  }},
  "main": "build/index.js",
  "types": "build/index.d.ts",
  "scripts": {{
    "build": "tsc -p ."
  }},
  "dependencies": {{
    "axios": "^0.22.0"
  }},
  "devDependencies": {{
    "typescript": "^4.4.3"
  }}
}}

"""

def main():
  os.chdir("src/apis")

  # generate api directory
  os.mkdir(projectname)
  os.chdir(projectname)

  open("index.ts", 'w').write(INDEX_TS)
  open("README.md", 'w').write(README_MD)
  open("package.json", 'w').write(PACKAGE_JSON)

  os.system("yarn")

  # update root directory ts files
  # src/apis/index.ts
  os.chdir("..")

  f_str = open("index.ts", 'r').read()
  f_str = f_str.replace("// import", f"import {{ {projectname} }} from \"./{projectname}\";\n// import")
  f_str = f_str.replace("// field", f"{projectname} = {projectname}.{ProjectName};\n  // field")

  open("index.ts", 'w').write(f_str)

  # src/index.ts
  os.chdir("..")
  with open("index.ts", 'a') as file:
    file.write(f"export {{ {projectname} }} from \"./apis/{projectname}\";\n")

  # updating tests
  os.chdir("__tests__/apis")
  open(f"{projectname}.spec.ts", 'w')

main()

#!/usr/bin/python

import os


Project_Name = input("Enter API name: ")
ProjectName = Project_Name.replace(" ", "")
projectname = ProjectName.lower()

LICENSE = f"""
// Copyright (c) 2021 <NAME>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// opies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

"""

INDEX_TS = f"""export namespace {projectname} {{
  export interface Options {{}}

  export class {ProjectName} {{
    options: Options;

    constructor(options: Options) {{
      this.options = options;
    }}
  }}
}}
"""

README_MD = f"""# {Project_Name}
### [API]()
## Usage

```sh
$ npm install @emissionapis/{projectname}
$ yarn install @emissionapis/{projectname}
```
```js
const {{ {projectname} }} = require("@emissionapis/{projectname}");
import {{ {projectname} }} from "@emissionapis/{projectname}";
```

**<NAME> <<EMAIL>>**

* Website: https://ltgr.github.io
* Github: [@ltgr](https://github.com/ltgr)
## License

Copyright © 2021 [<NAME> <<EMAIL>>](https://github.com/ltgr).<br />
This project is [MIT](https://github.com/ltgr/emissionapis/blob/main/LICENSE) licensed.

*Crafted with ❤️ by <NAME>*

"""

PACKAGE_JSON = f"""{{
  "name": "@emissionapis/{projectname}",
  "homepage": "https://github.com/ltgr/emissionapis/tree/main/src/apis/{projectname}",
  "version": "0.1.0",
  "author": "<NAME>",
  "license": "MIT",
  "description": "{projectname}",
  "repository": {{
    "type": "git",
    "url": "git+https://github.com/ltgr/emissionapis.git"
  }},
  "main": "build/index.js",
  "types": "build/index.d.ts",
  "scripts": {{
    "build": "tsc -p ."
  }},
  "dependencies": {{
    "axios": "^0.22.0"
  }},
  "devDependencies": {{
    "typescript": "^4.4.3"
  }}
}}

"""

def main():
  os.chdir("src/apis")

  # generate api directory
  os.mkdir(projectname)
  os.chdir(projectname)

  open("index.ts", 'w').write(INDEX_TS)
  open("README.md", 'w').write(README_MD)
  open("package.json", 'w').write(PACKAGE_JSON)

  os.system("yarn")

  # update root directory ts files
  # src/apis/index.ts
  os.chdir("..")

  f_str = open("index.ts", 'r').read()
  f_str = f_str.replace("// import", f"import {{ {projectname} }} from \"./{projectname}\";\n// import")
  f_str = f_str.replace("// field", f"{projectname} = {projectname}.{ProjectName};\n  // field")

  open("index.ts", 'w').write(f_str)

  # src/index.ts
  os.chdir("..")
  with open("index.ts", 'a') as file:
    file.write(f"export {{ {projectname} }} from \"./apis/{projectname}\";\n")

  # updating tests
  os.chdir("__tests__/apis")
  open(f"{projectname}.spec.ts", 'w')

main()
#!/usr/bin/python // Copyright (c) 2021 <NAME> // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // opies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. export namespace {projectname} {{   export interface Options {{}}    export class {ProjectName} {{     options: Options;      constructor(options: Options) {{       this.options = options;     }}   }} }} # {Project_Name} ### [API]() ## Usage  ```sh $ npm install @emissionapis/{projectname} $ yarn install @emissionapis/{projectname} ``` ```js const {{ {projectname} }} = require("@emissionapis/{projectname}"); import {{ {projectname} }} from "@emissionapis/{projectname}"; ```  **<NAME> <<EMAIL>>**  * Website: https://ltgr.github.io * Github: [@ltgr](https://github.com/ltgr) ## License  Copyright © 2021 [<NAME> <<EMAIL>>](https://github.com/ltgr).<br /> This project is [MIT](https://github.com/ltgr/emissionapis/blob/main/LICENSE) licensed.  *Crafted with ❤️ by <NAME>* {{   "name": "@emissionapis/{projectname}",   "homepage": "https://github.com/ltgr/emissionapis/tree/main/src/apis/{projectname}",   "version": "0.1.0",   "author": "<NAME>",   "license": "MIT",   "description": "{projectname}",   "repository": {{     "type": "git",     "url": "git+https://github.com/ltgr/emissionapis.git"   }},   "main": "build/index.js",   "types": "build/index.d.ts",   "scripts": {{     "build": "tsc -p ."   }},   "dependencies": {{     "axios": "^0.22.0"   }},   "devDependencies": {{     "typescript": "^4.4.3"   }} }} # generate api directory # update root directory ts files # src/apis/index.ts # src/index.ts # updating tests