@datacamp/learn-vm-scripts 0.0.1-rc.0

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.
Files changed (3) hide show
  1. package/README.md +46 -0
  2. package/dist/index.js +38 -0
  3. package/package.json +47 -0
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ ## learn-vm-scripts frontend repo
2
+
3
+ ### Installation
4
+
5
+ 1. Clone the repository:
6
+
7
+ ```sh
8
+ git clone https://github.com/your-repo/puppeteer-cli-login.git
9
+ cd puppeteer-cli-login
10
+ ```
11
+
12
+ 2. Use corret Node version
13
+
14
+ ```sh
15
+ nvm use
16
+ ```
17
+
18
+ 3. Install dependencies
19
+
20
+ ```sh
21
+ yarn install
22
+ ```
23
+
24
+ ### Configuration
25
+
26
+ This project uses environment variables to configure the `executablePath` and `userDataDir` for Puppeteer. The configuration is done using `.env` files.
27
+
28
+ #### Updating .env.development
29
+
30
+ The `.env.development` file should be updated with the values of your local Chrome installation:
31
+
32
+ ## Usage
33
+
34
+ The CLI tool accepts the following arguments:
35
+
36
+ - `--url`: The URL of the service to log in to.
37
+ - `--username`: The username for login.
38
+ - `--password`: The password for login.
39
+
40
+ ### Example
41
+
42
+ To log in to AWS:
43
+
44
+ ```sh
45
+ yarn cli -- --url "http://example.aws.amazon.com" --username "yourUsername" --password "yourPassword"
46
+ ```
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ import chalk from 'chalk';
2
+ import yargs from 'yargs';
3
+ import { loginToAWS } from './awsLogin.js';
4
+ import { loginToAzure } from './azureLogin.js';
5
+ import { loginToDatabricks } from './databricksLogin.js';
6
+ const argv = yargs(process.argv.slice(2))
7
+ .options({
8
+ password: { demandOption: true, type: 'string' },
9
+ url: { demandOption: true, type: 'string' },
10
+ username: { demandOption: true, type: 'string' },
11
+ })
12
+ .parseSync();
13
+ (async () => {
14
+ const { url } = argv;
15
+ const { username } = argv;
16
+ const { password } = argv;
17
+ console.log(chalk.blue(`Logging in to: ${url}`));
18
+ try {
19
+ if (url.includes('aws.amazon.com')) {
20
+ await loginToAWS(url, username, password);
21
+ }
22
+ else if (url.includes('portal.azure.com')) {
23
+ await loginToAzure(url, username, password);
24
+ }
25
+ else if (url.includes('databricks')) {
26
+ await loginToDatabricks(url, username, password);
27
+ }
28
+ else {
29
+ console.error(chalk.red('Unsupported URL'));
30
+ }
31
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
+ }
33
+ catch (error) {
34
+ console.error(chalk.red(`Error: ${error.message}`));
35
+ }
36
+ await new Promise(() => { });
37
+ })();
38
+ //# sourceMappingURL=index.js.map
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@datacamp/learn-vm-scripts",
3
+ "version": "0.0.1-rc.0",
4
+ "repository": "git@github.com:datacamp-engineering/learn-vm-scripts.git",
5
+ "description": "Scripts used by VMs in learn.",
6
+ "main": "./dist/index.js",
7
+ "bin": {
8
+ "vm-scripts": "./dist/index.js"
9
+ },
10
+ "type": "module",
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "dev": "NODE_ENV=development yarn build && yarn cli",
14
+ "lint": "eslint --ext ts .",
15
+ "deduplicate": "yarn-deduplicate",
16
+ "cli": "node dist/index.js"
17
+ },
18
+ "keywords": [],
19
+ "author": "Content Platform <content-platform@datacamp.com>",
20
+ "license": "UNLICENSED",
21
+ "dependencies": {
22
+ "chalk": "^5.3.0",
23
+ "dotenv": "^16.4.5",
24
+ "eslint-plugin-prettier": "^5.2.1",
25
+ "ora": "5.4.1",
26
+ "puppeteer-core": "^22.14.0",
27
+ "yargs": "^17.7.2"
28
+ },
29
+ "devDependencies": {
30
+ "@datacamp/eslint-config": "^7.1.0",
31
+ "@datacamp/prettier-config": "^4.0.0",
32
+ "@types/node": "^20.14.12",
33
+ "@types/puppeteer": "^7.0.4",
34
+ "@types/yargs": "^17.0.32",
35
+ "@typescript-eslint/eslint-plugin": "^7.17.0",
36
+ "@typescript-eslint/parser": "^7.17.0",
37
+ "eslint": "^8.32.0",
38
+ "eslint-config-prettier": "^9.1.0",
39
+ "eslint-plugin-jest": "^28.6.0",
40
+ "eslint-plugin-typescript-sort-keys": "^3.2.0",
41
+ "prettier": "3.0.3",
42
+ "ts-node": "^10.9.2",
43
+ "ts-node-dev": "^2.0.0",
44
+ "typescript": "^5.5.4",
45
+ "yarn-deduplicate": "^6.0.2"
46
+ }
47
+ }