Skip to content
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

Merged
merged 1 commit into from
Jan 19, 2018
Merged

Conversation

kjdelisle
Copy link
Contributor

@kjdelisle kjdelisle commented Jan 16, 2018

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 machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • Related API Documentation was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in packages/example-* were updated

@kjdelisle kjdelisle force-pushed the getting-started branch 5 times, most recently from a66ce45 to dd14e25 Compare January 16, 2018 18:15
@kjdelisle
Copy link
Contributor Author

@slnode test please

@@ -0,0 +1,25 @@
Copyright (c) IBM Corp. 2017. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2018

Copy link
Contributor Author

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?

@@ -0,0 +1,25 @@
Copyright (c) IBM Corp. 2017. All Rights Reserved.
Node module: @loopback/getting-started
Copy link
Contributor

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": {
Copy link
Contributor

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

Copy link
Contributor Author

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?

@kjdelisle kjdelisle force-pushed the getting-started branch 4 times, most recently from 5633a79 to f5ef471 Compare January 17, 2018 18:20
@@ -0,0 +1,25 @@
Copyright (c) IBM Corp. 2017-2018. All Rights Reserved.
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

@virkt25 virkt25 Jan 17, 2018

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';
Copy link
Contributor

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';
Copy link
Contributor

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';
Copy link
Contributor

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';
Copy link
Contributor

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';
Copy link
Contributor

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';
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor

@virkt25 virkt25 left a 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
Copy link
Contributor

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.

## Setup
1. Clone this repository if you haven't already:
```
git clone https://github.com/strongloop/loopback-next
Copy link
Contributor

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Member

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:

  1. npm install -g loopback4-cli
  2. lb4 example getting-started
  3. cd loopback4-example-getting-started
  4. npm install
  5. npm start

@bajtos
Copy link
Member

bajtos commented Jan 18, 2018

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

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?

I don't think we want people to install this from npm. npm install @loopback/example-getting-started will put the example package to node_modules/@loopback/example-getting-started and will not install any dev dependencies. People should use lb4 example getting-started to get a local copy of this example.

Copy link
Member

@bajtos bajtos left a 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.',
Copy link
Member

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/)
Copy link
Member

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.

Copy link
Member

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/)
Copy link
Member

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.

Copy link
Member

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
Copy link
Member

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:

  1. npm install -g loopback4-cli
  2. lb4 example getting-started
  3. cd loopback4-example-getting-started
  4. npm install
  5. npm start

"node": ">=8"
},
"scripts": {
"acceptance": "lb-dist mocha --opts ../../test/mocha.opts 'DIST/test/acceptance/**/*.js'",
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the second thought, since we are already keeping almost everything build/test related in @loopback/build, it will be easier to move mocha.opts to that package too. See #876.

If/when #876 is landed, then this line needs to be changed to --opts node_modules/@loopback/build/mocha.opts

Copy link
Member

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",
Copy link
Member

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
Copy link
Member

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.


export class TodoController {
constructor(
@inject('repositories.TodoRepository')
Copy link
Member

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

bajtos
bajtos previously requested changes Jan 19, 2018
Copy link
Member

@bajtos bajtos left a 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);
Copy link
Member

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.

@kjdelisle kjdelisle force-pushed the getting-started branch 2 times, most recently from 814d4f5 to c69d52b Compare January 19, 2018 17:47
@kjdelisle kjdelisle dismissed bajtos’s stale review January 19, 2018 18:13

Updated to incorporate feedback

The loopback4-example-getting-started repository is now being moved into the monorepo
@kjdelisle
Copy link
Contributor Author

@slnode test please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants