@into-cps-association/libms 0.5.1 → 0.5.3

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.
package/DEVELOPER.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Developer Instructions
2
2
 
3
+ ## Prerequisites
4
+
5
+ The **pm2** package needs to be available for tests.
6
+ You can install the same by executing
7
+
8
+ ```bash
9
+ npm install -g pm2
10
+ ```
11
+
3
12
  ## :gear: Configure
4
13
 
5
14
  This microservice needs library assets and configuration
@@ -26,34 +35,7 @@ yarn clean # Deletes "build", "coverage", "dist" and other temp files
26
35
  ```
27
36
 
28
37
  **NOTE:** The integration, end-to-end and http tests require a valid
29
- `.env` file. Here is a sample file.
30
-
31
- ```ini
32
- PORT='4001'
33
- MODE='local'
34
- LOCAL_PATH ='/Users/<Username>/DTaaS/files'
35
- LOG_LEVEL='debug'
36
- APOLLO_PATH='/lib'
37
- GRAPHQL_PLAYGROUND='true'
38
- ```
39
-
40
- Here is another with `git` mode.
41
-
42
- ```ini
43
- PORT='4001'
44
- MODE='git'
45
- LOCAL_PATH ='/Users/<Username>/DTaaS/files'
46
- LOG_LEVEL='debug'
47
- APOLLO_PATH='/lib'
48
- GRAPHQL_PLAYGROUND='true'
49
-
50
- GIT_USER1_REPO_URL='<git repo url>'
51
- GIT_USER1_API_TOKEN='<TOKEN>'
52
- ...
53
- GIT_USERX_REPO_URL='<git repo url>'
54
- GIT_USERX_API_TOKEN='<TOKEN>'
55
- ```
56
-
38
+ configuration. This configuration is already set in `libms.test.yaml` file.
57
39
 
58
40
  ## Service Endpoint
59
41
 
@@ -99,7 +81,7 @@ for more information publishing docker images.
99
81
  The default registry for npm packages is [npmjs](https://registry.npmjs.org).
100
82
 
101
83
  ```bash
102
- sudo npm install -g @into-cps-association/libms
84
+ npm install -g @into-cps-association/libms
103
85
  ```
104
86
 
105
87
  The steps for publishing the package to npmjs are listed in
@@ -134,17 +116,13 @@ running the following commands.
134
116
 
135
117
  The microservices require configuration and the docker version
136
118
  of the microservices uses the configuration
137
- file available in `config/.env.default`.
119
+ file available in `config/libms.dev.yaml`.
138
120
 
139
- Please add a `.env` file with the environment variables for
140
- the docker compose file to use.
141
- e.g.
121
+ For more see [configuration documentation](./README.md#gear-configure).
122
+ The `config/libms.dev.yaml` file is used for configuration of the container.
142
123
 
143
- ```sh
144
- PORT='4001'
145
- MODE='local'
146
- LOCAL_PATH='..\..\files'
147
- ```
124
+ A new directory named `files` is created in `servers/lib` directory and
125
+ files are saved and served from the `files` directory.
148
126
 
149
127
  ### Use
150
128
 
@@ -158,7 +136,7 @@ docker compose -f compose.lib.dev.yml up -d
158
136
 
159
137
  This command brings up the lib docker container and makes
160
138
  the website available at <http://localhost:4001>.
161
- The `config/.env.default` file is used as the microservice configuration.
139
+ The `config/libms.dev.yaml` file is used as the microservice configuration.
162
140
  If the configuration values are changed, please restart the container.
163
141
 
164
142
  ```bash
package/DOCKER.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # Overview
2
2
 
3
- The **libms microservice** is a simplified file manager providing graphQL API.
4
- It has two features:
3
+ The **lib microservice** is a simplified file manager which serves files
4
+ from local file system or public git repositories. It is possible to
5
5
 
6
- * provide a listing of directory contents.
7
- * transfer a file to user.
6
+ * Upload and download files from web browser
7
+ * Query available files and download them using GraphQL API
8
+ * Clone public git repositories and serve them as local files
8
9
 
9
10
  ## Use in Docker Environment
10
11
 
@@ -19,12 +20,13 @@ services:
19
20
  image: intocps/libms:latest
20
21
  restart: unless-stopped
21
22
  volumes:
23
+ - ./libms.yaml:/dtaas/libms/libms.yaml
22
24
  - ./files:/dtaas/libms/files
23
25
  ports:
24
26
  - "4001:4001"
25
27
  ```
26
28
 
27
- ### Create Files Directory
29
+ ### Create Files Directory (optional)
28
30
 
29
31
  The **libms microservice** serves files available from
30
32
  `files` directory.
@@ -47,6 +49,71 @@ files/
47
49
  Please create this `files` directory
48
50
  in the same file system location as that of the `compose.lib.yml` file.
49
51
 
52
+ :label: The directory structure is optional if you are using
53
+ libms as a standalone service.
54
+
55
+ ## :gear: Configure
56
+
57
+ The microservices requires config specified in `libms.yaml` file.
58
+ The template configuration file is:
59
+
60
+ ```yaml
61
+ port: '4001'
62
+ mode: 'local' #git or local
63
+ local-path: 'files'
64
+ log-level: 'debug'
65
+ apollo-path: '/lib'
66
+ graphql-playground: 'true'
67
+
68
+ git-repos: #only used in git mode
69
+ - user1:
70
+ repo-url: 'https://gitlab.com/dtaas/user1.git'
71
+ - user2:
72
+ repo-url: 'https://gitlab.com/dtaas/user2.git'
73
+ - common:
74
+ repo-url: 'https://gitlab.com/dtaas/common.git'
75
+ ```
76
+
77
+ The `local-path` variable is the relative filepath to the
78
+ location of the local directory which will be served to users
79
+ by the Library microservice.
80
+
81
+ Replace the default values the appropriate values for your setup.
82
+ Please save this config in `libms.yaml`.
83
+
84
+ ### Operation Modes
85
+
86
+ The mode indicates the backend storage for the files.
87
+ There are two possible modes - `local` and `git`.
88
+ The files available in the `local-path` are served to users in `local` mode.
89
+ In the `git` mode, the remote git repos are cloned and they are
90
+ served to users as local files. Only public git repositories
91
+ are supported at present.
92
+
93
+ #### git mode
94
+
95
+ A fragment of the config for `git` mode is:
96
+
97
+ ```yaml
98
+ ...
99
+ git-repos:
100
+ - user1:
101
+ repo-url: 'https://gitlab.com/dtaas/user1.git'
102
+ - user2:
103
+ repo-url: 'https://gitlab.com/dtaas/user2.git'
104
+ - common:
105
+ repo-url: 'https://gitlab.com/dtaas/common.git'
106
+ ```
107
+
108
+ Here, `user1`, `user2` and `common` are the local directories into which
109
+ the remote git repositories get cloned. The name of the repository need not
110
+ match with the local directory name. For example, the above configuration
111
+ enables library microservice to clone
112
+ `https://gitlab.com/dtaas/user1.git` repository into
113
+ `user1` directory. Any git server accessible over
114
+ HTTP(S) protocol is supported.
115
+ The `.git` suffix is optional.
116
+
50
117
  ### Run
51
118
 
52
119
  Use the following commands to start and stop the container respectively:
package/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # Overview
2
2
 
3
- The **lib microservice** is a simplified file manager providing graphQL API.
4
- It has two features:
3
+ The **lib microservice** is a simplified file manager which serves files
4
+ from local file system or public git repositories. It is possible to
5
5
 
6
- * provide a listing of directory contents.
7
- * transfer a file to user.
6
+ * Upload and download files from web browser
7
+ * Query available files and download them using GraphQL API
8
+ * Clone public git repositories and serve them as local files
8
9
 
9
10
  ## :arrow_down: Install
10
11
 
@@ -14,15 +15,9 @@ The default registry for npm packages is [npmjs](https://registry.npmjs.org).
14
15
  Install the package with the following commands
15
16
 
16
17
  ```bash
17
- sudo npm install -g @into-cps-association/libms
18
- sudo npm install -g pm2
18
+ npm install -g @into-cps-association/libms
19
19
  ```
20
20
 
21
- The package on [npmjs](https://registry.npmjs.org) is published
22
- less frequently than the one on Github NPM Registry. But
23
- the package on npmjs is more stable version of libms and should
24
- be used for production purposes.
25
-
26
21
  ### Github NPM Registry
27
22
 
28
23
  The package is also available in Github
@@ -31,8 +26,8 @@ The package is also available in Github
31
26
  Set the registry and install the package with the following commands
32
27
 
33
28
  ```bash
34
- sudo npm config set @into-cps-association:registry https://npm.pkg.github.com
35
- sudo npm install -g @into-cps-association/libms
29
+ npm config set @into-cps-association:registry https://npm.pkg.github.com
30
+ npm install -g @into-cps-association/libms
36
31
  ```
37
32
 
38
33
  The _npm install_ command asks for username and password. The username is
@@ -43,32 +38,64 @@ needs to have _read:packages_ scope.
43
38
 
44
39
  ## :gear: Configure
45
40
 
46
- The microservices requires config specified in INI format.
41
+ The microservices requires config specified in yaml format.
47
42
  The template configuration file is:
48
43
 
49
- ```ini
50
- PORT='4001'
51
- MODE='local' or 'gitlab'
52
- LOCAL_PATH ='/Users/<Username>/DTaaS/files'
53
- LOG_LEVEL='debug'
54
- APOLLO_PATH='/lib' or ''
55
- GRAPHQL_PLAYGROUND='false' or 'true'
56
-
57
- #Only needed if git mode
58
- GIT_USER1_REPO_URL='<git repo url>'
59
- GIT_USER1_API_TOKEN='<TOKEN>'
60
- ...
61
- GIT_USERX_REPO_URL='<git repo url>'
62
- GIT_USERX_API_TOKEN='<TOKEN>'
63
-
44
+ ```yaml
45
+ port: '4001'
46
+ mode: 'local' #git or local
47
+ local-path: '..\..\files'
48
+ log-level: 'debug'
49
+ apollo-path: '/lib'
50
+ graphql-playground: 'true'
51
+
52
+ git-repos: #only used in git mode
53
+ - user1:
54
+ repo-url: 'https://gitlab.com/dtaas/user1.git'
55
+ - user2:
56
+ repo-url: 'https://gitlab.com/dtaas/user2.git'
57
+ - common:
58
+ repo-url: 'https://gitlab.com/dtaas/common.git'
64
59
  ```
65
60
 
66
- The `LOCAL_PATH` variable is the absolute filepath to the
61
+ The `local-path` variable is the relative filepath to the
67
62
  location of the local directory which will be served to users
68
63
  by the Library microservice.
69
64
 
70
65
  Replace the default values the appropriate values for your setup.
71
- Please save this config in a file.
66
+ Please save this config in a file as a yaml file, for example as `libms.yaml`.
67
+
68
+ ### Operation Modes
69
+
70
+ The mode indicates the backend storage for the files.
71
+ There are two possible modes - `local` and `git`.
72
+ The files available in the `local-path` are served to users in `local` mode.
73
+ In the `git` mode, the remote git repos are cloned and they are
74
+ served to users as local files.
75
+
76
+ #### git mode
77
+
78
+ A fragment of the config for `git` mode is:
79
+
80
+ ```yaml
81
+ ...
82
+ git-repos:
83
+ - user1:
84
+ repo-url: 'https://gitlab.com/dtaas/user1.git'
85
+ - user2:
86
+ repo-url: 'https://gitlab.com/dtaas/user2.git'
87
+ - common:
88
+ repo-url: 'https://gitlab.com/dtaas/common.git'
89
+ ```
90
+
91
+ Here, `user1`, `user2` and `common` are the local directories into which
92
+ the remote git repositories get cloned. The name of the repository need not
93
+ match with the local directory name. For example, the above configuration
94
+ enables library microservice to clone
95
+ `https://gitlab.com/dtaas/user1.git` repository into
96
+ `user1` directory. Any git server accessible over
97
+ HTTP(S) protocol is supported.
98
+ The `.git` suffix is optional.
72
99
 
73
100
  ## :rocket: Use
74
101
 
@@ -82,7 +109,7 @@ The lib microservice is a file server. It supports file transfer
82
109
  over GraphQL and HTTP protocols.
83
110
 
84
111
  Options:
85
- -c, --config <file> provide the config file (default .env)
112
+ -c, --config <file> provide the config file (default libms.yaml)
86
113
  -H, --http <file> enable the HTTP server with the specified config
87
114
  -h, --help display help for libms
88
115
  ```
@@ -91,9 +118,9 @@ Both the options are not mandatory.
91
118
 
92
119
  ### Configuration file
93
120
 
94
- The config is saved `.env` file by convention. If `-c` is not specified
121
+ The config is saved `libms.yaml` file by convention. If `-c` is not specified
95
122
  The **libms** looks for
96
- `.env` file in the working directory from which it is run.
123
+ `libms.yaml` file in the working directory from which it is run.
97
124
  If you want to run **libms** without explicitly specifying the configuration
98
125
  file, run
99
126
 
@@ -108,11 +135,11 @@ libms -c FILE-PATH
108
135
  libms --config FILE-PATH
109
136
  ```
110
137
 
111
- If the environment file is named something other than `.env`,
112
- for example as `config/.env.default`, you can run
138
+ If the environment file is named something other than `libms.yaml`,
139
+ for example as `config/libms.yaml.default`, you can run
113
140
 
114
141
  ```sh
115
- libms -c "config/.env.default"
142
+ libms -c "config/libms.yaml.default"
116
143
  ```
117
144
 
118
145
  You can press `Ctl+C` to halt the application.
@@ -151,6 +178,7 @@ libms --http FILE-PATH
151
178
  "confirmCopy": true,
152
179
  "confirmMove": true,
153
180
  "showConfig": false,
181
+ "showDotFiles": false,
154
182
  "showFileName": true,
155
183
  "contact": false,
156
184
  "configDialog": false,
@@ -4,6 +4,7 @@ services:
4
4
  context: ../../
5
5
  dockerfile: ./docker/libms.dockerfile
6
6
  volumes:
7
- - ${LOCAL_PATH}:/dtaas/libms/files
7
+ - ./files:/dtaas/libms/files
8
+ - ./config/libms.dev.yaml:/dtaas/libms/libms.yaml
8
9
  ports:
9
- - ${PORT}:4001
10
+ - 4001:4001
package/compose.lib.yml CHANGED
@@ -3,6 +3,7 @@ services:
3
3
  image: intocps/libms:latest
4
4
  restart: unless-stopped
5
5
  volumes:
6
+ - ./config/libms.dev.yaml:/dtaas/libms/libms.yaml
6
7
  - ./files:/dtaas/libms/files
7
8
  ports:
8
9
  - "4001:4001"
@@ -0,0 +1,14 @@
1
+ port: '4001'
2
+ mode: 'local' #git or local
3
+ local-path: '/dtaas/libms/files'
4
+ log-level: 'debug'
5
+ apollo-path: '/lib'
6
+ graphql-playground: 'true'
7
+
8
+ git-repos: #only used in git mode
9
+ - user1:
10
+ repo-url: 'https://gitlab.com/dtaas/user1.git'
11
+ - user2:
12
+ repo-url: 'https://gitlab.com/dtaas/user2.git'
13
+ - common:
14
+ repo-url: 'https://gitlab.com/dtaas/common.git'
@@ -0,0 +1,14 @@
1
+ port: '4001'
2
+ mode: 'local' #git or local
3
+ local-path: '..\..\files'
4
+ log-level: 'debug'
5
+ apollo-path: '/lib'
6
+ graphql-playground: 'true'
7
+
8
+ git-repos: #only used in git mode
9
+ - user1:
10
+ repo-url: 'https://gitlab.com/dtaas/user1.git'
11
+ - user2:
12
+ repo-url: 'https://gitlab.com/dtaas/user2.git'
13
+ - common:
14
+ repo-url: 'https://gitlab.com/dtaas/common.git'