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

Seed Plugin #42

Merged
merged 8 commits into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7,777 changes: 7,039 additions & 738 deletions packages/contentstack-bulk-publish/package-lock.json

Large diffs are not rendered by default.

10,775 changes: 10,765 additions & 10 deletions packages/contentstack-clone/package-lock.json

Large diffs are not rendered by default.

5,518 changes: 5,507 additions & 11 deletions packages/contentstack-export-to-csv/package-lock.json

Large diffs are not rendered by default.

7,607 changes: 7,005 additions & 602 deletions packages/contentstack-export/package-lock.json

Large diffs are not rendered by default.

6,978 changes: 6,490 additions & 488 deletions packages/contentstack-import/package-lock.json

Large diffs are not rendered by default.

9,260 changes: 9,241 additions & 19 deletions packages/contentstack-plugins/package-lock.json

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions packages/contentstack-seed/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
Empty file.
11 changes: 11 additions & 0 deletions packages/contentstack-seed/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": [
"oclif",
"oclif-typescript"
],
"rules": {
"unicorn/no-abusive-eslint-disable": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/ban-ts-ignore": "off"
}
}
10 changes: 10 additions & 0 deletions packages/contentstack-seed/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*-debug.log
*-error.log
/.nyc_output
/dist
/lib
/tmp
/yarn.lock
node_modules
.DS_Store
coverage
65 changes: 65 additions & 0 deletions packages/contentstack-seed/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
## Description
This plugin allows you to quickly import existing Stacks that are needed to run sample apps.

<!-- usagestop -->
## Commands
<!-- commands -->
* [`csdx cm:seed`](#csdx-cmseed)

## `csdx cm:seed`

Create a Stack from existing content types, entries, assets, etc

```
USAGE
$ csdx cm:seed

OPTIONS
-r, --repo=repo GitHub account or GitHub account/repository

EXAMPLES
$ csdx cm:seed
$ csdx cm:seed -r "account"
$ csdx cm:seed -r "account/repository"
```

_See code: [src/commands/cm/seed.ts](https://github.com/contentstack/cli/blob/v1.0.5/src/commands/cm/seed.ts)_
<!-- commandsstop -->

## Advanced Flags
The following flags allow you to host and import Stacks from your own GitHub repository.
The account name can be a personal user account, organization account, or enterprise account.

```
$ csdx cm:seed -r "account/repository"
```

**Step 1.** Export a Stack

Identify a Stack that you would like to export.
This stack might be used in conjunction with a sample web site or mobile app you have created.

Now, run `csdx cm:export` against it. The following documentation explains the [Export Plugin](https://www.contentstack.com/docs/developers/cli/export-content-using-cli/).

In most cases, running `csdx cm:export -A` or `csdx cm:export -a "management token"` should work for you.

The `csdx cm:seed` plugin uses the same libraries as `csdx cm:import`.

**Step 2.** GitHub

Once the Stack is exported:

* Create a GitHub repository.
* By convention, your repository name should be prefixed with `stack-`. For example: `stack-your-starter-app`.
Doing so will allow the stack names to be found by the interactive prompt when running `csdx cm:seed -r "account"`.
This step is optional. You can fully qualify the repository name if required: `csdx cm:seed -r "account/repo`.
* Create a folder named `stack` within the newly created GitHub repository
* Take the content from **Step 1** and commit it to the `stack` folder
* Create a [Release](https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/managing-releases-in-a-repository)

The latest release will be downloaded and extracted, when a user attempts to install a Stack using:

```
$ csdx cm:seed -r "account"
$ csdx cm:seed -r "account/repository"
```
4 changes: 4 additions & 0 deletions packages/contentstack-seed/bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node

require('@oclif/command').run()
.catch(require('@oclif/errors/handle'))
3 changes: 3 additions & 0 deletions packages/contentstack-seed/bin/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\run" %*
12 changes: 12 additions & 0 deletions packages/contentstack-seed/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
"roots": [
"<rootDir>"
],
"testMatch": [
"**/tests/**/*.+(ts|tsx)",
"**/?(*.)+(spec|test).+(ts|tsx)"
],
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
},
}
Loading