This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhitelabelbuild
executable file
·103 lines (87 loc) · 2.72 KB
/
whitelabelbuild
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env php
<?php
require_once('./whitelabel/bootstrap.php');
if(wantsHelp()) {
$help = '';
$help .= "Usage: :script\n";
$help .= " --package-name=IXOPAY\n";
$help .= " --vendor-name=Payment\n";
$help .= " --production-host=gateway.ixopay.com\n";
$help .= " --sandbox-host=sandbox.ixopay.com\n";
$help .= " --vault-host=secure.ixopay.com\n";
$help = str_replace(
[':script'],
[get_included_files()[0]],
$help,
);
echo $help;
exit;
}
$prodHost = getProdHost();
$sandboxHost = getSandboxHost();
$vaultHost = getVaultHost();
$vendorName = pascalCase(getVendorName());
$packageName = pascalCase(getPackageName());
$version = '1.0.0';
$distFilenamePrefix = 'magento';
$distFilenameSuffix = '';
$srcDir = './Pgc';
$buildDir = sprintf('./build');
$newSrcDir = sprintf('%s/%s/%s', $buildDir, $vendorName, $packageName);
$distDir = './dist';
$distFilename = trim(
sprintf(
'%s-%s-%s-%s-%s',
$distFilenamePrefix,
kebabCase($vendorName),
kebabCase($packageName),
$version,
$distFilenameSuffix,
),
'-',
);
if(empty(isHostValid($prodHost))) {
error('--production-host is invalid');
usage();
exit;
}
if(empty(isHostValid($sandboxHost))) {
error('--sandbox-host is invalid');
usage();
exit;
}
if(empty(isHostValid($vaultHost))) {
error('--vault-host is invalid');
usage();
exit;
}
// Cleanup from previous build
deleteDir($buildDir);
deleteDir($distDir);
highlight('Whitelabel Build Script');
// Static string, we have to remove
$replacementMap = [
'Pgc\\\\Pgc\\\\' => sprintf('%s\\\\%s\\\\', $vendorName, $packageName), // compose paths
'pgc/pgc-magento' => strtolower(sprintf('%s/%s-magento', $vendorName, $packageName)), // composer's package name
'gateway.ixopay.com' => $prodHost, // Prod gateway host
'sandbox.ixopay.com' => $sandboxHost, // Sandbox gateway host
'secure.ixopay.com' => $vaultHost, // Vault host
'Pgc\\Pgc' => sprintf('%s\\%s', $vendorName, $packageName), // PHP namespace
'Pgc_Pgc' => sprintf('%s_%s', $vendorName, $packageName), // Package identifer
'pgc_pgc' => sprintf('%s_%s', strtolower($vendorName), strtolower($packageName)), // frontend identifier
'Pgc' => $vendorName, // vendor prefix
'pgc' => strtolower($vendorName), // vendor identifier
];
info(sprintf(
'Building %s with module identifier "%s_%s"',
$distFilename,
$vendorName,
$packageName,
));
build($srcDir, $newSrcDir, $replacementMap);
info(sprintf(
'Creating zip file %s.zip',
$distFilename,
));
zipBuildToDist($buildDir, $distDir, $distFilename, get_included_files()[0]);
success('Build complete');