capacitor-standard-version 1.0.1 → 1.0.2

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,11 @@
1
+ export const readVersion = (contents) => {
2
+ const version = contents.split('versionName "')[1].split('"')[0]
3
+ return version
4
+ }
5
+
6
+ export const writeVersion = (contents, version) => {
7
+ const newContent = contents.replace(/(.*(?:versionName[ \t]+).*)/g, ` versionName "${version}"`)
8
+ const versionCode = Number(version.split('.').map(v => v.length === 1 ? `0${v}` : v).join(''))
9
+ const finalContent = newContent.replace(/(.*(?:versionCode[ \t]+).*)/g, ` versionCode "${versionCode}"`)
10
+ return finalContent
11
+ }
@@ -0,0 +1,49 @@
1
+ import standardVersion from 'standard-version';
2
+ import { getConfiguration } from 'standard-version/lib/configuration';
3
+ import merge from 'merge-deep';
4
+ import * as ios from './ios';
5
+ import * as android from './android';
6
+
7
+ const baseConfig = {
8
+ noVerify: true,
9
+ tagPrefix: '',
10
+ releaseCommitMessageFormat: "chore(release): {{currentTag}} [skip ci]",
11
+ packageFiles: [
12
+ {
13
+ filename: "./package.json",
14
+ type: "json"
15
+ },
16
+ ],
17
+ bumpFiles: [
18
+ {
19
+ filename: "./android/app/build.gradle",
20
+ updater: android
21
+ },
22
+ {
23
+ filename: "./package.json",
24
+ type: "json"
25
+ },
26
+ {
27
+ filename: "./package-lock.json",
28
+ type: "json"
29
+ },
30
+ {
31
+ filename: "./ios/App/App.xcodeproj/project.pbxproj",
32
+ updater: ios
33
+ }
34
+ ]
35
+ }
36
+
37
+ async function run() {
38
+ try {
39
+ const config = getConfiguration();
40
+ // merge base config with user config
41
+ const finalConfig = merge(baseConfig, config);
42
+ await standardVersion(finalConfig);
43
+ } catch (error) {
44
+ console.error(error);
45
+ throw error;
46
+ }
47
+ }
48
+
49
+ run();
package/src/bin/ios.ts ADDED
@@ -0,0 +1,11 @@
1
+ export const readVersion = (contents) => {
2
+ const marketingVersionString = contents.match(/MARKETING_VERSION = [0-9]*.[0-9]*.[0-9]*/)
3
+ const version = marketingVersionString.toString().split('=')[1].trim()
4
+ return version
5
+ }
6
+
7
+ export const writeVersion = (contents, version) => {
8
+ const newContent = contents.replace(/(.*(?:MARKETING_VERSION[ \t]+).*)/g, ` MARKETING_VERSION = "${version}"`)
9
+ const finalContent = newContent.replace(/(.*(?:CURRENT_PROJECT_VERSION[ \t]+).*)/g, ` CURRENT_PROJECT_VERSION "${version}"`)
10
+ return finalContent
11
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "esModuleInterop": true,
5
+ "target": "es6",
6
+ "moduleResolution": "node",
7
+ "sourceMap": true,
8
+ "outDir": "dist",
9
+ "baseUrl": "src",
10
+ "lib": ["es2016", "dom"]
11
+ },
12
+ "include": ["src/**/*"],
13
+ "exclude": ["node_modules", "__tests__", "**/*.spec.ts"]
14
+ }
@@ -0,0 +1,30 @@
1
+ const path = require('path');
2
+ const webpack = require('webpack');
3
+ const nodeExternals = require('webpack-node-externals');
4
+ const { CheckerPlugin } = require('awesome-typescript-loader');
5
+ console.log(process.env.NODE_ENV || 'production');
6
+ module.exports = {
7
+ mode: process.env.NODE_ENV || 'production',
8
+ target: 'node',
9
+ externals: [nodeExternals()],
10
+ entry: './src/bin/index.ts',
11
+ module: {
12
+ rules: [
13
+ {
14
+ test: /\.ts$/,
15
+ use: 'awesome-typescript-loader',
16
+ exclude: /node_modules/,
17
+ },
18
+ ],
19
+ },
20
+ devtool: process.env.NODE_ENV === 'development' ? 'eval-source-map' : undefined,
21
+ watch: process.env.NODE_ENV === 'development',
22
+ plugins: [new CheckerPlugin(), new webpack.BannerPlugin({ banner: '#!/usr/bin/env node', raw: true })],
23
+ resolve: {
24
+ extensions: ['.ts', '.js'],
25
+ },
26
+ output: {
27
+ filename: 'index.js',
28
+ path: path.resolve(__dirname, 'dist'),
29
+ },
30
+ };