@simplelocalize/cli 2.9.2 → 2.9.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.
@@ -0,0 +1,35 @@
1
+ name: CI & Publish
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-node@v4
16
+ with:
17
+ node-version: '20'
18
+ cache: 'npm'
19
+ - run: npm ci
20
+
21
+ publish:
22
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
23
+ needs: test
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+ - uses: actions/setup-node@v4
28
+ with:
29
+ node-version: '20'
30
+ registry-url: 'https://registry.npmjs.org/'
31
+ - run: npm ci
32
+ - run: npm run build --if-present
33
+ - run: npm publish --access public
34
+ env:
35
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/README.md CHANGED
@@ -6,26 +6,21 @@ in their workflows.
6
6
 
7
7
  ## Installation
8
8
 
9
- ```
10
- npm install @simplelocalize/cli@2.9.1
9
+ ```shell
10
+ npm install @simplelocalize/cli
11
11
  ```
12
12
 
13
13
  After installing the package, it should automatically choose the right binary for
14
14
  your system and install it into `node_modules/.bin` directory, to make it available for your
15
15
  scripts in `package.json`.
16
16
 
17
- ## Usage
18
-
19
- Package SimpleLocalize CLI in your project and makes it available in `package.json` scripts.
20
-
21
-
22
- ```
17
+ ```json
23
18
  {
24
19
  "name": "My project",
25
20
  "version": "1.0.0",
26
21
  "private": true,
27
22
  "dependencies": {
28
- "@simplelocalize/cli": "^2.9.1",
23
+ "@simplelocalize/cli": "^2.9.2",
29
24
  },
30
25
  "scripts": {
31
26
  "start": "react-scripts start",
@@ -38,15 +33,23 @@ Package SimpleLocalize CLI in your project and makes it available in `package.js
38
33
 
39
34
  Learn more about [SimpleLocalize CLI commands](https://github.com/simplelocalize/simplelocalize-cli)
40
35
 
36
+
37
+ ## NPX Support
38
+
39
+ You can also use `npx` to run SimpleLocalize CLI commands without installing the package
40
+ globally:
41
+
42
+ ```shell
43
+ npx @simplelocalize/cli download
44
+ ```
45
+
41
46
  ## Versioning explanation
42
47
 
43
48
  `@simplelocalize/cli` versioning is synced with https://github.com/simplelocalize/simplelocalize-cli versioning.
44
49
 
45
- `@simplelocalize/cli@{CLI_VERSION}-release.{NPM_VERSION}` is the versioning scheme used in this package.
46
- Where `CLI_VERSION` is the version of SimpleLocalize CLI and `NPM_VERSION` is the version of this npm package.
47
-
48
50
  `@simplelocalize/cli@2.9.1` will install SimpleLocalize CLI 2.9.x and this npm package version is 1.
49
51
  `@simplelocalize/cli@2.9.1` will install SimpleLocalize CLI 2.9.x and this npm package version is 2.
50
52
 
51
53
  By using this versioning scheme, we can release new versions of this npm package
52
- without changing the SimpleLocalize CLI version, for example, to fix bugs in this package.
54
+ without changing the SimpleLocalize CLI version, for example, to fix bugs in this package,
55
+ and follow semantic versioning rules.
package/index.cjs CHANGED
@@ -60,25 +60,33 @@ const buildDownloadBinaryUrl = (version) => {
60
60
  }
61
61
 
62
62
  async function installBinary() {
63
- const packageVersion = require('./package.json').version;
64
- const cliVersion = getExpectedCliVersion
63
+ const cliVersion = getExpectedCliVersion();
64
+ if (fs.existsSync(binaryPath)) {
65
+ console.log('Removing existing binary...');
66
+ fs.unlinkSync(binaryPath);
67
+ }
65
68
  const downloadUrl = buildDownloadBinaryUrl(cliVersion);
66
69
  if (!fs.existsSync(path.join(__dirname, 'bin'))) {
67
70
  fs.mkdirSync(path.join(__dirname, 'bin'));
68
71
  }
69
72
 
70
- const response = await axios({
71
- url: downloadUrl,
72
- method: 'GET',
73
- responseType: 'stream'
74
- });
75
-
76
- const writer = fs.createWriteStream(binaryPath);
77
- response.data.pipe(writer);
78
- await new Promise((resolve, reject) => {
79
- writer.on('finish', resolve);
80
- writer.on('error', reject);
81
- });
73
+ try {
74
+ const response = await axios({
75
+ url: downloadUrl,
76
+ method: 'GET',
77
+ responseType: 'stream'
78
+ });
79
+
80
+ const writer = fs.createWriteStream(binaryPath);
81
+ response.data.pipe(writer);
82
+ await new Promise((resolve, reject) => {
83
+ writer.on('finish', resolve);
84
+ writer.on('error', reject);
85
+ });
86
+ } catch (error) {
87
+ console.error('Error downloading SimpleLocalize CLI binary:', error.message);
88
+ process.exit(1);
89
+ }
82
90
 
83
91
  // Make it executable (only on Unix-based systems)
84
92
  if (os.platform() !== 'win32') {
@@ -94,7 +102,7 @@ async function installBinary() {
94
102
 
95
103
  const linkToNodeModulesBin = () => {
96
104
  let nodeModulesBinPath = path.join(__dirname, '..', '..', '.bin', 'simplelocalize');
97
-
105
+
98
106
  if (os.platform() === 'win32') {
99
107
  nodeModulesBinPath += '.exe';
100
108
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplelocalize/cli",
3
- "version": "2.9.2",
3
+ "version": "2.9.3",
4
4
  "description": "SimpleLocalize CLI for NPM",
5
5
  "main": "index.cjs",
6
6
  "type": "module",