4.1.4 • Published 10 months ago

@cogeco-web/core v4.1.4

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
10 months ago

< Back to main

@cogeco-web/core

Library of Typescript core types, interfaces, classes and functions used at Cogeco across multiple projects

Installation

yarn add @cogeco-web/core

or

npm install @cogeco-web/core

Usage

Example

import { ExampleType } from '@cogeco-web/core'

const myObject: ExampleType = {
  title: 'My Title',
}

Adding a new type, interface, classe or util function

Here are the steps in order to add a new object to the library.

  1. Within /packages/core/src/, locate the folder (interfaces, models, utils, etc..) which corresponds to the type of object you want to create. If you don't find an existing folder that matches the type of object you want to create, make a new one (using camelCase).
  2. Create a new file inside the corresponding folder (interfaces, models, utils, etc..) with the name of your object. Use PascalCase to name your file. Example: interfaces/ExampleType.ts
  3. Put your code in the new file and make sure you export it with same name as the file you created. For Example:
interface ExampleType {
  title: string
}

export default ExampleType
  1. Adding a dependency library for your new component (OPTIONAL)
    If you need to install a dependency library for your new component, install it using the following script (via terminal, at the root fo the repo, NOT within the /packages/components folder)
    A - If it's a dev dependency

    npx lerna add --scope=@cogeco-web/core -D my-npm-library-name

    B - Otherwise

    npx lerna add --scope=@cogeco-web/core my-npm-library-name
  2. Open the ./src/index.ts file and then:

        - Add an import for your newly created object

import ExxampleType from './interfaces/ExampleType'

        - Add the object to the list of exported objects (Note: Please try to keep the exports organized alphabetically)

export {
  ...
  ExxampleType
  ...
}
  1. Now that you are done, run the follwing scripts (at the root fo the repo, NOT within the /packages/core folder).
    This will update the definition files and create a new build, hence making your new component available to use within other packages of the library.
yarn install
yarn build
  1. Documentation — To be added

Reference

For reference, check the ExampleType