GithubHelp home page GithubHelp logo

sakuraapi / cli Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 1.0 215 KB

Command Line Interface for Scaffolding and Managing SakuraAPI Projects

License: BSD 3-Clause "New" or "Revised" License

Shell 1.45% TypeScript 88.78% JavaScript 6.41% HTML 3.37%
cli javascript nodejs sakuraapi typescript

cli's People

Contributors

carsonf avatar etsuo avatar stevenschobert avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

candleshine

cli's Issues

Going into infinite loop while configuring JWT role.

Steps to reproduce

  1. create a project using Sapi init sakura-test.
  2. follow the description and provide inputs until JWT role
    ** What JWT role does this server fulfill?: (none)
    select i)issuer
    ? Server JWT Issuer Name: localhost
    ? Server JWT Signing Key: BbI.4DdtAuHGGYOHYWya}Ox*EF3&6+oH

then it will ask for audiences
? Audience Server Name: localhost:5050
? Audience Server Key: "=BQgkEl:rCwuj&J#vk,#wS_)Ho4zC[+

it will loop continuously there is no specified way to exit from the loop.

if I forcefully exited the process then all my actions and data loss.so here there should be a way to exit from the loop while configuring the issuer.

Newly scaffolded project throws node warnings

npm WARN deprecated [email protected]: ๐Ÿ“ซ Please upgrade to v3.1.5 (v3.0.x had a core bug with attachments and v3.1.5 now supports Node v6.4.0+). Also read the breaking changes for upgrading from v2 to v3 at https://github.com/niftylettuce/email-templates#v3-breaking-changes ๐Ÿ“ซ
Testing implications of upgrading versions.

sapi init should properly scaffold tests

describe('Password', () => {
  let sapi;
  beforeEach(() => {
    sapi = testSapi({
      providers: [
        PasswordService
      ]
    });
  });

  afterEach(() => {
    sapi.deregisterDependencies();
  });

  it(...) // whatever this is being done now
});

Update dependencies & misc problems

  • fix problem with npx jamine test
  • .gitignore isn't getting copied from template for some reason
  • bodyParser.json missing
  • refactor / enhance how email is setup for auth authorities
  • specs aren't found when npm test is run

Implement generators for new Models, Services and Routables

This has become expecially important because of how mixins work (don't work?) with TypeScript 2.6 (see: microsoft/TypeScript#9944).

So, for example to get an @Model working, there's an export tap dance that needs to happen:

import {
  Db,
  IDbGetParams,
  IFromDbOptions,
  Json,
  Model,
  SakuraApi,
  SapiModelMixin
}            from '@sakuraapi/api';
import {
  Collection,
  CollectionInsertOneOptions,
  CollectionOptions,
  Cursor,
  Db as MongoDb,
  DeleteWriteOpResultObject,
  InsertOneWriteOpResult,
  ObjectID,
  ReplaceOneOptions,
  UpdateWriteOpResult
}            from 'mongodb';
import {dbs} from '../config/db';

export {
  Collection,
  CollectionInsertOneOptions,
  CollectionOptions,
  Cursor,
  MongoDb,
  DeleteWriteOpResultObject,
  InsertOneWriteOpResult,
  ObjectID,
  ReplaceOneOptions,
  UpdateWriteOpResult,
  IDbGetParams,
  IFromDbOptions,
  SakuraApi
};

@Model({
  dbConfig: dbs.user
})
export class User extends SapiModelMixin() {
}

That's a lot of setup work. It looks like TypeScript issue 9944 is scheduled to have some sort of solution in 2.8, so revisit the issue then. In the meantime, sapi cli needs to reduce the pain in setting up a model.

Might as well create generators for Services and Routables at the same time.

update generated spec/config/environment.ts

import * as environment from '../../src/config/environment';

...

  dbConnections: [
    ...(environment as any).dbConnections
  ],

This will make it less confusing when setting up databases. If an integrator wants their test environment to be totally different, they can change this, but by default setup tests to rely on the main environment file for less confusing initial configuration.

Re-running sapi init on an existing project with jwt type none adds email dependencies

If you run sapi init over an existing project, it should let you diff changes. If that project was setup with jwt type none, on the second sapi init, it inserts:

    "email-templates": "^3.2.0",
    "nodemailer": "^4.0.1",
    "@types/email-templates": "^3.1.0",

into package.json. It should not unless the user changed the jwt target to auth-authority.

Use template-literal instead of EJS

Template Literal is fastest, smallest and simplest template engine, because it use JS's literal template feature.

It's 55 times faster than EJS, and it also use less CPU and RAM ressources, so it may be a good idea to use it instead of EJS ๐Ÿ˜€

sapi init LogService.ts mutates error

fix:

  private buildJsonObj(message: any, err?: Error): object {
    const obj = typeof message === 'string' ? {message} : Object.assign({}, message);

    obj.serverCity = LogService.city;
    obj.serverCountry = LogService.country;
    obj.serverExternalHostname = LogService.externalHostname;
    obj.serverHostname = LogService.hostName;
    obj.serverIp = LogService.ip;
    obj.serverNodeEnv = LogService.nodeEnv;

    if (err) {
      obj.error = errorToJsonString(err);
    } else if (message instanceof Error) {
      obj.error = errorToJsonString(message);
    }

    return obj;
  }

`outdated-update` feature

Walk through npm outdated and choose per outdated dependency whether to skip, update to wanted, or update to latest... then run unit tests... then repeat until all is done.

Database config generator

This should be able to parse existing environment json and ts files for both spec config and normal config to add, edit, delete DB config.

Ideally, it would expect various config files to be in a particular place, but would allow you to designate alternative paths if files aren't where they're expected to be. One example of this would be the dbs.ts file.

On the TS side of things, some kind of AST parsing would be nice: http://blog.scottlogic.com/2017/05/02/typescript-compiler-api-revisited.html

generated password allows `'` character

$ sapi init aaaa
SakuraAPI Cli v0.6.3
Initialized empty Git repository in /Users/daniel/Documents/projects/sandbox/aaaa/.git/
โœ“ Loaded default preferences from /Users/daniel/.sapi
package.json preferences:
? Author: daniel
? Description: SakuraApi Awesome Sauce
? License: UNLICENSED
? Project Name (npm name): aaaa
? Version: 0.0.0
src/config/environment.ts preferences:
? What JWT role does this server fulfill?: (none) issuer
? Server JWT Issuer Name issuer.Daniels-MacBook-Pro.local
? Server JWT Signing Key: @',7>QOwPt~DTFE>i#>g~a,%(!579tu[

see the second character of the generated signingKey

This will cause the generated project not to npm start

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.