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

publish r11s with an entry file #3504

Merged
merged 7 commits into from
Sep 8, 2020
Merged

publish r11s with an entry file #3504

merged 7 commits into from
Sep 8, 2020

Conversation

znewton
Copy link
Contributor

@znewton znewton commented Sep 3, 2020

In order to blend development of FRS with the open-sourced Routerlicious components, we need to be able to consume as much as possible from OSS without manually copy-pasting updates between the 2 repos. This PR exports some modules defined in Routerlicious in a way that makes them consumable as a typed NPM package.

@tanviraumi
Copy link
Contributor

@curtisman We have probably stopped publishing r11s package. Was that only because no one is using it? FRS team wants to import some of it so that they don't have to copy paste. Also let us know if you have a better recommendation for doing this.

@curtisman
Copy link
Member

curtisman commented Sep 3, 2020

If these are reusable pieces, may be it is a good idea to break them out into new packages? Would that make sense? The routerlicious package seem like there are a lot of different pieces, it feels weird to have some being reusable while other doesn't.

@tanviraumi
Copy link
Contributor

They are mostly rest apis and a few wrappers. Breaking up also feels weird cause the pieces don't make much sense independently.

How about the readme explains the exported pieces? And how they are expected to be used?

@ghost ghost added the triage label Sep 3, 2020
@curtisman
Copy link
Member

Yeah... readme and tsdoc for the API exported will be good. Although it is strange that they don't much sense independently, but you are only exporting pieces to be reused :)

To make this publish, you need to remove the private field in package.json, change the namespace to @ fluidframework (remember to update the namespace in the README's title as well).

To push to to NPM you need to release it. If you can target this to 0.26 branch, I can make a patch release with this package as well.

@znewton
Copy link
Contributor Author

znewton commented Sep 4, 2020

While this change does indeed only explicitly export from Riddler and Alfred, we will also be utilizing the other components published in the @fluidframework/server-routerlicious package, like so:

# docker-compose.yml
# ...
    deli:
        build:
            context: .
            target: runner
        command: node packages/routerlicious/dist/kafka-service/index.js deli /usr/src/server/node_modules/@fluidframework/server-routerlicious/dist/deli/index.js
        environment:
            - DEBUG=fluid:*
            - NODE_ENV=development
        restart: always
# ...

and

# deli-deployment.yaml
# ...
command:
          - 'node'
          - 'packages/routerlicious/dist/kafka-service/index.js'
          - 'deli'
          - '/usr/src/server/node_modules/@fluidframework/server-routerlicious/dist/deli/index.js'
# ...

Whereas we'll be using the Riddler and Alfred packages as imports within the source code itself. For example, we need to have a custom RiddlerResourceFactory but everything else about Riddler will be the same, so Riddler will look like so:

// riddler/www.ts
// ...
import { RiddlerResourcesFactory, RiddlerRunnerFactory } from "./runnerFactory";
// ...

utils.runService(
    new RiddlerResourcesFactory(),
    new RiddlerRunnerFactory(),
    "riddler",
    config,
);
// riddler/runnerFactory.ts
/*!
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License.
 */
import * as services from "@fluidframework/server-services";
import { getOrCreateRepository } from "@fluidframework/server-services-client";
import { MongoManager } from "@fluidframework/server-services-core";
import * as utils from "@fluidframework/server-services-utils";
import { Provider } from "nconf";
import * as winston from "winston";
import { RiddlerRunner, RiddlerResources, ITenantDocument } from "@fluidframework/server-routerlicious";

export class RiddlerResourcesFactory implements utils.IResourcesFactory<RiddlerResources> {
    public async create(config: Provider): Promise<RiddlerResources> {
        // ...
        // special closed-source implementation
        // ...

        return new RiddlerResources(
            tenantsCollectionName,
            mongoManager,
            port,
            loggerFormat,
            serverUrl,
            defaultHistorianUrl,
            defaultInternalHistorianUrl);
    }
}

export class RiddlerRunnerFactory implements utils.IRunnerFactory<RiddlerResources> {
    public async create(resources: RiddlerResources): Promise<utils.IRunner> {
        return new RiddlerRunner(
            resources.tenantsCollectionName,
            resources.port,
            resources.mongoManager,
            resources.loggerFormat,
            resources.baseOrdererUrl,
            resources.defaultHistorianUrl,
            resources.defaultInternalHistorianUrl);
    }
}

As Tanvir mentioned, it would probably be good for me to include this type of info in the README, but I hope this helps give a better sense of the intended use. I'll push up an updated README tomorrow.

@tanviraumi
Copy link
Contributor

tanviraumi commented Sep 4, 2020

Thanks @znewton for the explanation. Along with the readme, also make the changes into package.json. Once this is merged, we will ping Curtis for the patch release. You can start consuming it after.

I do think there are better ways to structure the dependencies so that it looks less weird. I have opened an issue (#3528). We should follow up on this soon.

@znewton
Copy link
Contributor Author

znewton commented Sep 4, 2020

Looks like Layer Check is failing in the repo-policy-check because

ERROR: Package missing from PackageNode @fluid-internal/server-routerlicious

How do I fix this? It is not something I've seen before, but I'm assuming it has something to do with changing from @fluid-internal/server-routerlicious to @fluidframework/server-routerlicious 😄

@tanviraumi
Copy link
Contributor

Looks like a failure in validation scripts. @curtisman any idea on how to fix it?

@curtisman
Copy link
Member

@znewton please update the package name in tools\build-tools\data\layinfo.json

@znewton
Copy link
Contributor Author

znewton commented Sep 8, 2020

Thanks, @curtisman ! The build is now passing 🎉

@tanviraumi tanviraumi merged commit 595a09b into microsoft:main Sep 8, 2020
@znewton znewton deleted the export-r11s-classes branch September 8, 2020 16:57
@znewton znewton restored the export-r11s-classes branch September 8, 2020 17:08
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.

4 participants