@quadnix/octo-build 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,9 @@
1
1
  # <%= name %>
2
2
  <%= description %>
3
3
 
4
+ ## Octo Documentation
5
+ [Official Docs](http://octo.quadnix.com/)
6
+
4
7
  ## Installation
5
8
  ```bash
6
9
  npm install
@@ -12,9 +15,70 @@ Before running the app, ensure,
12
15
 
13
16
  ## Development
14
17
  ```bash
15
- # Build app
18
+ # Build app. This will compile your TypeScript code, and copy necessary static assets into the dist directory.
16
19
  npm run build
17
20
 
18
21
  # Run app. This will create the infrastructure defined in your app.
19
- npm start
22
+ # It will also move the generated static assets back into the src directory.
23
+ npm run start:dev
24
+ ```
25
+
26
+ ## Destroy
27
+ ### Step 1
28
+ In `module-definitions.ts`, comment out all modules except the `app` and `account` modules.
29
+ The app and account modules load AWS credentials to call AWS APIs, hence they remain uncommented.
30
+
31
+ By deleting the `s3-website-service-module` module below,
32
+ you are safely deleting the s3-website resources created by this module.
33
+
34
+ ```typescript
35
+ // Example for 'aws-s3-website' template.
36
+ private init(): void {
37
+ this.add(SimpleAppModule, 'app-module', { name: 'aws-s3-website' });
38
+
39
+ this.add(AwsIniAccountModule, 'account-module', {
40
+ accountId: config.AWS_ACCOUNT_ID,
41
+ app: stub<App>('${{app-module.model.app}}'),
42
+ });
43
+
44
+ // this.add(AwsS3StaticWebsiteServiceModule, 's3-website-service-module', {
45
+ // account: stub<Account>('${{account-module.model.account}}'),
46
+ // awsRegionId: 'us-east-1',
47
+ // bucketName: config.AWS_S3_WEBSITE_BUCKET_NAME,
48
+ // directoryPath: websiteSourcePath,
49
+ // });
50
+ }
51
+ ```
52
+
53
+ ### Step 2
54
+ Then, simply re-build and run your app again.
55
+
56
+ ```bash
57
+ npm run build
58
+ npm run start:dev
20
59
  ```
60
+
61
+ ## Note
62
+ ### Managing Octo State
63
+ Octo works by managing the state of your infrastructure.
64
+ To keep track of the state, octo will use a `StateProvider`.
65
+
66
+ By default, octo uses the `LocalStateProvider` as defined in your `main.ts` file.
67
+ This state provider will write the state into the `.octo` directory,
68
+ whose location is also defined in your `main.ts` file.
69
+
70
+ Since your app is in TypeScript, it needs to be compiled into the `dist` directory before it can run.
71
+ During the build process, we copy the existing state from `src/.octo` into the `dist/.octo` directory.
72
+ This allows Octo to load the before state while processing your infrastructure changes.
73
+
74
+ If the state was not copied over, the Octo will attempt to re-create the same infrastructure again, and might fail.
75
+ E.g. in case of 'aws-s3-website' template, the same S3 bucket will attempt to be created, and might throw errors.
76
+
77
+ Once the app is run using `npm run start:dev`, the state is generated in the `dist` directory,
78
+ and after the run, we copy the new state back to the `src` directory.
79
+ This way, the next run will use the new state, and not attempt to re-create the same infrastructure again.
80
+
81
+ ### Managing Octo State in Production
82
+ The `LocalStateProvider` is not suitable for production because of all the file management involved.
83
+ In production, we recommend using a different `StateProvider` that stores the state outside of your codebase.
84
+ To get more information on other state providers, please reference [Octo Docs](http://octo.quadnix.com/).
@@ -41,11 +41,13 @@
41
41
  "name": "<%= name %>",
42
42
  "private": true,
43
43
  "scripts": {
44
- "build": "rimraf dist && tsc -p tsconfig.build.json && npm run copy-assets",
45
- "copy-assets": "copyfiles -u 1 -a <%- copyGlobs %> dist/",
44
+ "build": "rimraf dist && tsc -p tsconfig.build.json && npm run copy-assets-dist",
45
+ "copy-assets-dist": "copyfiles -u 1 -a <%- copyGlobs %> dist/",
46
+ "copy-assets-src": "copyfiles -u 1 -a \"dist/.octo/**/*\" src/",
46
47
  "format": "prettier --write \"src/**/*.ts\"",
47
48
  "lint": "eslint .",
48
49
  "start": "node dist/main.js",
50
+ "start:dev": "npm start && npm run copy-assets-src",
49
51
  "test": "NODE_OPTIONS=--experimental-vm-modules jest --testRegex=\"\\.spec.ts$\"",
50
52
  "test:e2e": "NODE_OPTIONS=--experimental-vm-modules jest --testRegex=\"\\.e2e-spec.ts$\""
51
53
  },
package/package.json CHANGED
@@ -90,5 +90,5 @@
90
90
  },
91
91
  "type": "module",
92
92
  "types": "./dist/index.d.ts",
93
- "version": "0.0.7"
93
+ "version": "0.0.8"
94
94
  }