npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

capacitor-typeorm-cli

v0.0.2

Published

Capacitor SQLite TypeOrm CLI

Downloads

6

Readme

Maintainers

| Maintainer | GitHub | Social | | ----------------- | ----------------------------------------- | ------ | | Quéau Jean Pierre | jepiqueau | |

Installing the CLI

npm install -g capacitor-typeorm-cli

For Typescript projects two others packages are required to be installed

npm install --save-dev @types/node 
npm install --save-dev ts-node

Supported Command

| Name | Description | :--------------------- | :------------------------------ | | migration-generate | Generate typeorm migration file |

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! All the others commands from the typeOrm CLI are not supported. ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

To get the list of commands via the Help run

npx capacitor-typeorm-cli -h

Output

Usage: capacitor-typeorm-cli [options] [command]

A CLI tool for generating migrations for Capacitor SQite TypeOrm

Options:
  -V, --version                 output the version number
  -h, --help                    display help for command

Commands:
  migration-generate [options]  generate typeorm migration file
  help [command]                display help for command

Usage migration-generate

Get it from the Help

npx capacitor-typeorm-cli help migration-generate

Output

Usage: capacitor-typeorm-cli migration-generate [options]

generate typeorm migration file

Options:
  -c, --command <commandName>      Alias command name
  -e, --entity <entityPath>        Alias for entity path
  -m, --migration <migrationPath>  Alias for migration path
  -i, --indexJs [indexJs]          Alias Index file extension for Javascript
                                   instead of Typescript
  -db, --database [databasePath]   Alias for database path
  -o, --outputJs [outputJs]        Generate a migration file on Javascript
                                   instead of Typescript
  -t, --timestamp [timestamp]      Custom timestamp for the migration name
  -h, --help                       display help for command

EntityPath (Mandatory)

The entityPath refers to the directory containing entity files, particularly the index.ts file. This index.ts file should export all entities. For example:

import { Item } from './item';
import { User } from './user';

export { User, Item };

MigrationPath (Mandatory)

The migrationPath denotes the directory where migration files, generated by the CLI, are stored. Initially, an index.ts file must be created in this directory as follows:

export {  };

IndexJs (Optional)

The indexJs parameter is utilized to specify the file extension for the index file. If set to true, the extension will be .js for JavaScript files; otherwise, the default extension will be .ts for TypeScript files.

DatabasePath (Optional)

This parameter specifies the path to the database where the web database has been stored on disk for generating refactoring migrations. It is not required for the initial migration generation.

OutputJs (Optional)

When set to true, this parameter instructs the CLI to generate the migration files in JavaScript. By default, the files are generated in TypeScript.

Timestamp (Optional)

If you need to specify a timestamp for the migration name, use the -t option (alias for --timestamp) and provide the timestamp (should be a non-negative number). If not provided, the default timestamp is obtained from Date.now().

Project Folder Structure

src/ | ... | entities/ ... / (if needed) | index.ts | user.ts | ... | migrations/
... / (if needed) | index.ts | ...

Package.json Scripts

Add Capacitor Typeorm command under scripts section in package.json

  • For commonjs project

    "scripts": {
        ...
        "captypeorm": "typeorm-ts-node-commonjs"
    }
  • For ESM project

    "scripts": {
        ...
        "captypeorm": "capacitor-typeorm-esm",
    }
  • Then add scripts to generate the migrations

    "scripts": {
        ...
      "cap:typeorm:migration:initialAuthor": "npm run captypeorm migration-generate -- src/databases/entities/author src/databases/migrations/author/InitialAuthorPost",
      "cap:typeorm:migration:refactorAuthor": "npm run captypeorm migration-generate -- -m src/databases/migrations/author/RefactorAuthorPost -t 1234567890123 -db ABSOLUTE_PATH_TO_YOUR_DB -e src/databases/entities/author",
    
    }
  • In case one do not want to use the script captypeorm , one can define the script like this For ESM module

    "scripts": {
        ...
      "cap:typeorm:migration:initialAuthor": "npx capacitor-typeorm-esm migration-generate src/databases/entities/author src/databases/migrations/author/InitialAuthorPost",
      "cap:typeorm:migration:refactorAuthor": "npx capacitor-typeorm-esm migration-generate -m src/databases/migrations/author/RefactorAuthorPost -t 1234567890123 -db ABSOLUTE_PATH_TO_YOUR_DB -e src/databases/entities/author",
    
    }

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!