forked from symplely/zend-ffi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.ignore_autoload.php
98 lines (84 loc) · 2.06 KB
/
.ignore_autoload.php
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
<?php
declare(strict_types=1);
if (!\defined('DS'))
\define('DS', \DIRECTORY_SEPARATOR);
function recursiveDelete($directory, $options = [])
{
if (!isset($options['traverseSymlinks']))
$options['traverseSymlinks'] = false;
$files = \array_diff(\scandir($directory), ['.', '..']);
foreach ($files as $file) {
$dirFile = $directory . \DS . $file;
if (\is_dir($dirFile)) {
if (!$options['traverseSymlinks'] && \is_link(\rtrim($file, \DS))) {
\unlink($dirFile);
} else {
\recursiveDelete($dirFile, $options);
}
} else {
\unlink($dirFile);
}
}
return \rmdir($directory);
}
$directory = '.' . \DS;
$composerJson = [
"name" => "/",
"description" => "Some library as a FFI extension.",
"keywords" => [],
"homepage" => "https://github.com/",
"license" => "",
"authors" => [
[
"name" => "",
"email" => ""
]
],
"type" => "project",
"require" => [
"php" => ">7.4",
"ext-ffi" => "*",
"symplely/zend-ffi" => ">0.9.0"
],
"autoload" => [
"files" => [
"preload.php"
],
"psr-4" => [
"" => "./"
]
],
"autoload-dev" => [
"psr-4" => [
"" => "tests/"
]
],
"scripts" => [
"post-create-project-cmd" => [
"php .ignore_autoload.php",
"composer update -d ../..",
]
]
];
\unlink($directory . 'composer.json');
\file_put_contents(
$directory . 'composer.json',
\json_encode($composerJson, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)
);
print "- Initialized `autoload` & `require` composer.json" . \PHP_EOL;
\unlink(__FILE__);
\rename('.ignore_autoload_skeleton.php', '.ignore_autoload.php');
\unlink('preload.php');
\rename('preload_skeleton.php', 'preload.php');
\unlink('ffi_extension.php');
\rename('ffi_extension_skeleton.php', 'ffi_extension.php');
\rename('.gitattributes.skeleton', '.gitattributes');
\rename('.gitignore.skeleton', '.gitignore');
\rename('.ci', '.github');
\unlink('LICENSE');
\recursiveDelete('headers');
\recursiveDelete('zend');
\mkdir('headers');
\mkdir('lib');
\mkdir('src');
\mkdir('tests');