@ariga/atlas 0.10.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.
- package/README.md +14 -0
- package/install.js +82 -0
- package/package.json +19 -0
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Atlas CLI
|
|
2
|
+
Atlas is a language-agnostic tool for managing and migrating database schemas using modern DevOps principles.
|
|
3
|
+
|
|
4
|
+
## Getting Started
|
|
5
|
+
|
|
6
|
+
### Run the CLI
|
|
7
|
+
To install it globally, run:
|
|
8
|
+
```bash
|
|
9
|
+
npx -g @ariga/atlas help
|
|
10
|
+
```
|
|
11
|
+
otherwise, run:
|
|
12
|
+
```bash
|
|
13
|
+
npx @ariga/atlas help
|
|
14
|
+
```
|
package/install.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import fetch from "node-fetch";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import {execFile} from "child_process";
|
|
8
|
+
|
|
9
|
+
// Mapping from Node's `process.arch` to Golang's `$GOARCH`
|
|
10
|
+
const ARCH_MAPPING = {
|
|
11
|
+
x64: "amd64",
|
|
12
|
+
arm64: "arm64",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// Mapping between Node's `process.platform` to Golang's
|
|
16
|
+
const PLATFORM_MAPPING = {
|
|
17
|
+
darwin: "darwin",
|
|
18
|
+
linux: "linux",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getPlatform = () => {
|
|
22
|
+
const arch = ARCH_MAPPING[process.arch];
|
|
23
|
+
if (!arch) {
|
|
24
|
+
console.error(`Unsupported architecture: ${process.arch}`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
const platform = PLATFORM_MAPPING[process.platform];
|
|
28
|
+
if (!platform) {
|
|
29
|
+
console.error(`Unsupported platform: ${process.platform}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
return platform + "-" + arch;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const getPackageVersion = () => {
|
|
36
|
+
const jsonPath = path.join(".", "package.json")
|
|
37
|
+
const pkgJson = JSON.parse(fs.readFileSync(jsonPath, "utf8"));
|
|
38
|
+
return pkgJson.version;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const installURL = "https://atlasgo.sh?test=1"
|
|
42
|
+
const installScriptPath = "./install.sh"
|
|
43
|
+
const binPath = "./atlas"
|
|
44
|
+
|
|
45
|
+
// download the atlas installation script from installURL
|
|
46
|
+
const getInstallScript = async () => {
|
|
47
|
+
const resp = await fetch(installURL);
|
|
48
|
+
return await resp.text();
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
function runInstallScript(path, version, platform) {
|
|
52
|
+
// TODO remove the darwin-arm64 check once we publish tagged binaries for darwin-arm64
|
|
53
|
+
if (version !== undefined && platform !== "darwin-arm64") {
|
|
54
|
+
version = "v" + version;
|
|
55
|
+
} else {
|
|
56
|
+
version = "latest";
|
|
57
|
+
}
|
|
58
|
+
process.env["ATLAS_VERSION"] = version;
|
|
59
|
+
const args = ["--no-install", "--output", binPath, "--platform", platform, "-y", "--user-agent", "atlas-npm"];
|
|
60
|
+
return new Promise((resolve) => {
|
|
61
|
+
execFile(path, args, (error, stdout, stderr) => {
|
|
62
|
+
if (error) {
|
|
63
|
+
console.warn(error);
|
|
64
|
+
}
|
|
65
|
+
console.info(stdout);
|
|
66
|
+
resolve(stdout? stdout : stderr);
|
|
67
|
+
console.log("Installed Atlas successfully");
|
|
68
|
+
// make the binary executable
|
|
69
|
+
fs.chmodSync(binPath, 0o744);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function main() {
|
|
75
|
+
const script = await getInstallScript();
|
|
76
|
+
await fs.promises.writeFile(installScriptPath, script, {mode: 0o744});
|
|
77
|
+
const version = getPackageVersion();
|
|
78
|
+
const platform = getPlatform();
|
|
79
|
+
await runInstallScript(installScriptPath, version, platform);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
await main();
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ariga/atlas",
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Atlas is a language-agnostic tool for managing and migrating database schemas using modern DevOps principles",
|
|
6
|
+
"author": "",
|
|
7
|
+
"bugs": "https://github.com/ariga/atlas/issues",
|
|
8
|
+
"license": "LICENSE\n This distribution of Atlas is licensed under the Ariga End User License Agreement\n available at https://ariga.io/legal/atlas/eula.\n By using this software, you accept the terms described in the license.",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"preinstall": "node install.js"
|
|
11
|
+
},
|
|
12
|
+
"bin": {
|
|
13
|
+
"atlas": "atlas"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://atlasgo.io",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"node-fetch": "^3.3.1"
|
|
18
|
+
}
|
|
19
|
+
}
|