-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(getting-started): migrate into monorepo #869
Conversation
a66ce45
to
dd14e25
Compare
@slnode test please |
packages/getting-started/LICENSE
Outdated
@@ -0,0 +1,25 @@ | |||
Copyright (c) IBM Corp. 2017. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, this is a migration of existing licensed code; should it change to 2018, or be 2017-2018?
packages/getting-started/LICENSE
Outdated
@@ -0,0 +1,25 @@ | |||
Copyright (c) IBM Corp. 2017. All Rights Reserved. | |||
Node module: @loopback/getting-started |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name the package as @loopback/example-getting-started
to be consistent with @loopback/example-codehub
?
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add "private" : true,
so that the module won't be published to npmjs? See https://github.com/strongloop/loopback-next/blob/master/packages/example-codehub/package.json#L8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want this one to be published to npmjs, so that people can install it as a ready-made example, don't we?
5633a79
to
f5ef471
Compare
@@ -0,0 +1,25 @@ | |||
Copyright (c) IBM Corp. 2017-2018. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright years are separated by a comma. So 2017,2018
.
@@ -0,0 +1,14 @@ | |||
// Copyright IBM Corp. 2017. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2017, 2018
.
@@ -0,0 +1,14 @@ | |||
// Copyright IBM Corp. 2017. All Rights Reserved. | |||
// Node module: loopback4-example-getting-started |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module name: @loopback/example-getting-started
year: 2017, 2018
@@ -0,0 +1,57 @@ | |||
import {Application, ApplicationConfig} from '@loopback/core'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't there a a copyright header here?
@@ -0,0 +1 @@ | |||
export * from './todo.controller'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright header?
@@ -0,0 +1,12 @@ | |||
import {DefaultCrudRepository, DataSourceType} from '@loopback/repository'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyright header?
@@ -0,0 +1,112 @@ | |||
import {createClientForHandler, expect, supertest} from '@loopback/testlab'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyright header?
@@ -0,0 +1,36 @@ | |||
import {Todo} from '../src/models/index'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyright header?
@@ -0,0 +1,125 @@ | |||
import {expect} from '@loopback/testlab'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyright header?
@@ -0,0 +1,3 @@ | |||
*.tgz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file isn't needed as it's covered by top-level .gitignore
.
864ccbc
to
cf3dfb8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know the tool picked the year as 2018 ... but like you said, since this was a move, shouldn't it be 2017,2018.
If not then change LICENSE to be consistent and just 2018
as well.
## Setup | ||
1. Clone this repository if you haven't already: | ||
``` | ||
git clone https://github.com/strongloop/loopback4-example-getting-started |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be updated to use the new lb4 example getting-started
command ... and it should be enabled in the CLI.
a389a10
to
66cc62a
Compare
a0b1b20
to
007de04
Compare
## Setup | ||
1. Clone this repository if you haven't already: | ||
``` | ||
git clone https://github.com/strongloop/loopback-next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update this to use lb4 example getting-started
instead of cloning the mono-repo. You should be good after this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, the correct instructions are along the following lines:
npm install -g loopback4-cli
lb4 example getting-started
cd loopback4-example-getting-started
npm install
npm start
I don't think we want people to install this from npm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! I found few places to improve, but I am ok with leaving those improvements for a follow-up pull request if it makes your work easier.
Once this PR is landed, we need to update https://github.com/strongloop/loopback4-example-getting-started - remove all files except README, shorten README to a link pointing people to this new location. Please don't forget to cross-link the pull requests!
@@ -13,6 +13,8 @@ const utils = require('../../lib/utils'); | |||
|
|||
const EXAMPLES = { | |||
codehub: 'A GitHub-like application we used to use to model LB4 API.', | |||
'getting-started': | |||
'A basic Todo application used as an introduction to LoopBack 4.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, this description should match the description in package.json
. See https://github.com/strongloop/loopback-next/pull/869/files#diff-27ee36b5a6726e3a1fa485380948168aR4:
"description": "An application and tutorial on how to build with LoopBack 4.",
|
||
Before we can begin, you'll need to make sure you have some things installed: | ||
- [Node.js](https://nodejs.org/en/) at v6.x or greater | ||
- [TypeScript](http://www.typescriptlang.org/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A global installation of TypeScript should not be needed, typescript should be a dev-dependency of this package.
I know this is probably out of scope of this PR, but since we have to update the instructions anyways (see below), then I think it's best to fix this part too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kjdelisle PTAL ☝️ this hasn't been addressed yet.
Before we can begin, you'll need to make sure you have some things installed: | ||
- [Node.js](https://nodejs.org/en/) at v6.x or greater | ||
- [TypeScript](http://www.typescriptlang.org/) | ||
- [Git](https://git-scm.com/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Git should not be needed, because people are going to obtain this example via lb4 example
command.
Please update the instructions accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kjdelisle PTAL ☝️ this hasn't been addressed yet.
## Setup | ||
1. Clone this repository if you haven't already: | ||
``` | ||
git clone https://github.com/strongloop/loopback-next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, the correct instructions are along the following lines:
npm install -g loopback4-cli
lb4 example getting-started
cd loopback4-example-getting-started
npm install
npm start
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"acceptance": "lb-dist mocha --opts ../../test/mocha.opts 'DIST/test/acceptance/**/*.js'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, --opts ../../test/mocha.opts
will not work after this example project is cloned via lb4 example
command. We need to fix lb4 example
to extract monorepo-level mocha.opts
into test/mocha.opts
and fix all package.json scripts referring to mocha.opts
. Since test/mocha.opts
is the default location loaded by Mocha, we should simply remove --opts
argument completely.
Feel free to leave this fix out of scope of this PR, I think this may be easier to test once the master
branch contains an example project using mocha.opts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: #876 has been landed, package scripts will need an update after this feature branch is rebased on top of the new master
.
"pretest": "npm run build:current", | ||
"test": "lb-dist mocha --opts ../../test/mocha.opts 'DIST/test/unit/**/*.js' 'DIST/test/acceptance/**/*.js'", | ||
"unit": "lb-dist mocha --opts ../../test/mocha.opts 'DIST/test/unit/**/*.js'", | ||
"verify": "npm pack && tar xf loopback-getting-started*.tgz && tree package && npm run clean", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loopback-getting-started*.tgz
will not exist, because the package name is @loopback/example-getting-started
. I think we can afford to simplify the wildcard to something like tar xf *getting-started-*.tgz
"example", | ||
"tutorial" | ||
], | ||
"private": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind moving the private
flag closer to the top of the file, e.g. just after version
or description
field? I think this is a pretty important flag, and when it's specified at the bottom of the file, then it's easy to miss when reading package.json.
007de04
to
08f40ea
Compare
|
||
export class TodoController { | ||
constructor( | ||
@inject('repositories.TodoRepository') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be @repository(TodoRepository.name)
to better support refactor-rename operations. See #744
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
@post('/todo') | ||
async create(@param.body('obj') obj: Todo): Promise<Todo> { | ||
return await this.todoRepository.create(obj); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yesterday you mentioned that this pull request is not only copying over files from loopback4-example-getting-started repository, but also making changes in the actual implementation. That's really bad, how are we supposed to find the differences and review those changes?
The code in the original repository contains many important TODO comments that we need to address for our MVP milestone.
In this particular place, the original createTodo
method has additional hand-written validation as a workaround for missing #118. This validation should be preserved, or at least we should discuss whether and how we want to change this implementation bit.
Please update this pull request to copy as many source files in verbatim as is possible. Additional changes/updates/refactorings should be made in follow-up pull requests, only once the current codebase has been added to monorepo with as little modifications as possible.
814d4f5
to
c69d52b
Compare
c69d52b
to
bbb3af5
Compare
The loopback4-example-getting-started repository is now being moved into the monorepo
bbb3af5
to
395a34e
Compare
@slnode test please |
The loopback4-example-getting-started repository is now being moved into the monorepo
blocks #727
implements a part of #836
Checklist
npm test
passes on your machinepackages/cli
were updatedpackages/example-*
were updated